For this Question: There is an integer array nums having n integers, given as input. Find out whether the given array is spirally sorted or not.

<b>Note:</b>
An array nums, having N elements is spirally sorted if nums[0] ≤ nums[N – 1] ≤ nums[1] ≤ nums[N – 2] …An integer n (size of array nums) is given as input. In the Second line, n space-separated integers are given as input.

<b>Constraints</b>
1 &le; n &le; 10<sup>5</sup>
0 &le; nums[i] &le; 5*10<sup>4</sup>
0 &le; i &le; n-1Print "YES" if Array is Spirally sorted else "NO"(without quotes).Sample Input 1:
7
1 10 14 20 18 12 5 

Sample Output 1:
YES
 
Explanation: 
arr[0] < arr[6]
arr[1] < arr[5]
arr[2] < arr[4]
Therefore, the required output is YES.

Sample Input 2:
4
1 2 4 3 

Sample Output 2:
NO, I have written this Solution Code: import java.io.*;
import java.security.KeyStore.Entry;
import java.util.*;


public class Main{
	public static int[] arr=new int[1005];
	public static List<Integer> ls=new ArrayList<>();
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		int mx=(n+1)/2;
		for(int i=0;i<mx;i++){
			if(arr[i]>arr[n-i-1]){
				System.out.println("NO");
				return;
			}
			if(i>0&&arr[i]<Math.max(arr[i-1], arr[n-i])){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		return;
    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?