For this Question: You have a sequence p1, p2, p3..., pn which is a permutation of {1, 2, 3, ..., n}. You can do the following operation at most 1 time:
Choose 2 indices i and j. Swap (pi, pj).
Can you sort the permutation.The first line of the input contains an integer n, the number of elements in the permutation.
The second line contains p1, p2, ..., pn.

Constraints
2 <= n <= 100Output "YES" if it is possible to sort the permutation, else output "NO".Sample Input
5
5 2 3 4 1

Sample Output
YES

Explanation: We can swap p1, p5.

Sample Input:
5
5 1 2 4 3

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



class Main {
	public static void inputArr(BufferedReader read, int[] arr,int arrSize) throws IOException {

		String[] str = read.readLine().trim().split(" ");

		for(int i = 0; i < arrSize; i++){
			arr[i] = Integer.parseInt(str[i]);
		}

	}
	public static void main (String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		int arrSize = Integer.parseInt(read.readLine());

		int[] arr = new int[arrSize];

		inputArr(read, arr, arrSize);

		int count = 0;

		for(int i = 0; i < arrSize; i++)
			if(arr[i] != i+1)
				count++;

		if(count>2)
			System.out.println("NO");
		else
			System.out.println("YES");
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?