import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String dummyN = sc.nextLine(); dummyN sc.nextLine() sc.nextLine sc int N = Integer.parseInt(dummyN); N Integer.parseInt(dummyN) Integer.parseInt Integer dummyN String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] lines = line.split(" "); lines line.split(" ") line.split line " " int[] array = new int[N]; array new int[N] N for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			array[i] = Integer.parseInt(lines[i]);
		} {
			array[i] = Integer.parseInt(lines[i]);
		} array[i] = Integer.parseInt(lines[i]) array[i] array i Integer.parseInt(lines[i]) Integer.parseInt Integer lines[i] lines i int num1 = -1; num1 -1 1 int num2 = -1; num2 -1 1 for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		} int i = 0; int i = 0; i 0 i < array.length-1 i array.length-1 array.length array array.length 1 i++ i++ i {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		} {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		} if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			} array[i] > array[i+1] array[i] array i array[i+1] array i+1 i 1 {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			} if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				} num1 < 0 num1 0 {
					num1 = i;
				} num1 = i num1 i {
					num2 = i+1;
				} num2 = i+1 num2 i+1 i 1 if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		} num1 != -1 && num2 != -1 num1 != -1 num1 -1 1 num2 != -1 num2 -1 1 {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		} int temp = array[num1]; temp array[num1] array num1 array[num1] = array[num2] array[num1] array num1 array[num2] array num2 array[num2] = temp array[num2] array num2 temp boolean flag = true; flag true for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		} int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		} {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		} if(array[i] != i+1) {
				flag = false;
				break;
			} array[i] != i+1 array[i] array i i+1 i 1 {
				flag = false;
				break;
			} flag = false flag false break; if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		} flag {
			System.out.println("YES");
		} System.out.println("YES") System.out.println System.out System System.out "YES" {
			System.out.println("NO");
		} System.out.println("NO") System.out.println System.out System System.out "NO" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String dummyN = sc.nextLine();
		int N = Integer.parseInt(dummyN);

		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] array = new int[N];

		for(int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(lines[i]);
		}

		int num1 = -1;
		int num2 = -1;

		for(int i = 0; i < array.length-1; i++) {
			if(array[i] > array[i+1]) {
				if(num1 < 0) {
					num1 = i;
				}else {
					num2 = i+1;
				}

			}
		}

		if(num1 != -1 && num2 != -1) {
			int temp = array[num1];
			array[num1] = array[num2];
			array[num2] = temp;
		}

		boolean flag = true;
		for(int i = 0; i < array.length; i++) {
			if(array[i] != i+1) {
				flag = false;
				break;
			}
		}

		if(flag) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}
