import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	}

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

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] P = new int[N]; P new int[N] N int[] Q = new int[N]; Q new int[N] N int a; a for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		} {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		} P[i] = sc.nextInt() P[i] P i sc.nextInt() sc.nextInt sc a = P[i] a P[i] P i Q[i] = a Q[i] Q i a int count = 0; count 0 for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		} int i = 0; int i = 0; i 0 i < N - 1 i N - 1 N 1 i++ i++ i {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		} {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		} for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			} int j = N - 1; int j = N - 1; j N - 1 N 1 j > i j i j-- j-- j {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			} {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			} if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				} P[j - 1] > P[j] P[j - 1] P j - 1 j 1 P[j] P j {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				} int tmpNum = P[j - 1]; tmpNum P[j - 1] P j - 1 j 1 P[j - 1] = P[j] P[j - 1] P j - 1 j 1 P[j] P j P[j] = tmpNum P[j] P j tmpNum for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		} {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		} if (Q[i] - P[i] != 0) {
				count++;
			} Q[i] - P[i] != 0 Q[i] - P[i] Q[i] Q i P[i] P i 0 {
				count++;
			} count++ count if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		} count <= 2 count 2 {
			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);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			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);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		int a;

		for (int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			a = P[i];
			Q[i] = a;
		}

		int count = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = N - 1; j > i; j--) {
				if (P[j - 1] > P[j]) {
					int tmpNum = P[j - 1];
					P[j - 1] = P[j];
					P[j] = tmpNum;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (Q[i] - P[i] != 0) {
				count++;
			}
		}
		if(count <= 2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}

	}

}