For this Question: Write a Java program to perform following operations: 
1. Input an arraylist of size n 
2. Sort the arraylist 
3. Search for value 2 in arraylist , if present print out its index else print out -1.First line of input contains value of n.
second line of input contains n space-separated integers.

Constraints:-
1 < = N < = 1000
1 < = Arr[i] < = 100000 Print index of 2 if present else print out -1.Sample Input:-
6
1 2 3 4 5 6

Sample output:-
1

Explanation:
2 is present at index value 1 in the sorted arraylist., I have written this Solution Code: import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        int index = Collections.binarySearch(list, 2);

        if (index >= 0) {
            System.out.println(index);
        } else {
           System.out.println("-1");
        }
        sc.close();
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?