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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] array = new int[n]; array new int[n] n int[] array_sort = new int[n]; array_sort new int[n] n int p; p int count = 0; count 0 String str = "YES"; str "YES" for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		} {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		} p = scan.nextInt() p scan.nextInt() scan.nextInt scan array[i] = p array[i] array i p array_sort[i] = p array_sort[i] array_sort i p Arrays.sort(array_sort) Arrays.sort Arrays array_sort for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		} {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		} if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			} array[i] != array_sort[i] array[i] array i array_sort[i] array_sort i {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			} count++ count if (count == 3) {
					str = "NO";
					break;
				} count == 3 count 3 {
					str = "NO";
					break;
				} str = "NO" str "NO" break; System.out.println(str) System.out.println System.out System System.out str String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_sort = new int[n];
		int p;
		int count = 0;
		String str = "YES";
		for (int i = 0; i < n; i++) {
			p = scan.nextInt();
			array[i] = p;
			array_sort[i] = p;
		}
		Arrays.sort(array_sort);
		for (int i = 0; i < n; i++) {
			if (array[i] != array_sort[i]) {
				count++;
				if (count == 3) {
					str = "NO";
					break;
				}
			}
		}
		System.out.println(str);

	}
}
