Help me in solving DSAJ03 problem

My issue

The 1st line of input contains 2 space space separated integers -

N and

K
The 2nd line of input contains

N space separated integers - the elements of an array

My code

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // Read N and K from the first line of input
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        // Create an array to store the elements
        int[] array = new int[N];
      //System.out.println(N+ " "+K );
     for(int i=0;i<N;i++){
         
         array[i]=scanner.nextInt();
        
     }
        for(int i=0;i<N;i++){
        if(K==array[i]){
            System.out.println("YES "+K);
            break;
        }
        else if(N==array[i]){
            System.out.println("YES "+N);
            break;
        }
         
             
        }



    }
}

Learning course: DSA using Java
Problem Link: CodeChef: Practical coding for everyone