For this Question: You are given an array <b>A</b> of size <b>N</b>. You need to find the integer not present in this array that is closest to <b>K</b>. The closeness between two numbers A[i] and A[j] is defined as <b>abs(A[i] - A[j])</b>. 

For Example:
For given array A = [1,2,5,6,13]
For given K = 12
Output: 12

Explanation: numbers missing 3, 4, 7,8, 9, 10, 11, 12, 14, 15....
and K = 12, so distance from each missing number is (3,9), (4,8), ....
where every pair denotes (missing number, distance) hence 12 is answer.The first line of the input contains two integers N and K.

Constraints
1 <= N <= 1000
1 <= A[i] <= 10000
1 <= K <= 10000

(The array may not contain all distinct numbers)Output the required closest number.Sample Input
5 6
4 7 10 6 5

Sample Output
8

Explanation: Closeness of 8 is 2. There is no such number that has closeness lesser than this and is not a part of array.

Sample Input
5 10
4 7 10 6 5

Sample Output
9, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args)throws IOException {

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] str=br.readLine().split(" ");
        int N=Integer.parseInt(str[0]);
        int K=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int[] arr=new int[N];
        for(int i=0;i<N;i++)
        {
            arr[i]=Integer.parseInt(str[i]);
        }
        Arrays.sort(arr);
        int i=0;
        boolean flag=false;
        int index=binarySearch(arr,0,N-1,K-i);
        while(index!=-1)
        {
            i++;
            index=binarySearch(arr,0,index,K-i);
            if(index!=-1)
            {
               index=binarySearch(arr,index,N-1,K+i);
            }
            else
            flag=true;
        }
        if(flag)
        System.out.print(K-i);
        else
        System.out.print(K+i);
    }
    public static int binarySearch(int[] arr,int start,int end,int key)
    {
        while(start<=end)
        {
           int mid=(start+end)/2;
           if(arr[mid]==key)
           return mid;
           else if(arr[mid]>key)
           end=mid-1;
           else
           start=mid+1;
        }
        return -1;
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?