import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 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) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	} main {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int cnt = sc.nextInt(); cnt sc.nextInt() sc.nextInt sc int[] nums = new int[cnt]; nums new int[cnt] cnt for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
			nums[i] = sc.nextInt();
		} {
			nums[i] = sc.nextInt();
		} nums[i] = sc.nextInt() nums[i] nums i sc.nextInt() sc.nextInt sc int falseCnt = 0; falseCnt 0 for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		} int i = 0; int i = 0; i 0 i < cnt i cnt i++ i++ i {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		} {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		} if (nums[i] != i + 1) {
				falseCnt++;
			} nums[i] != i + 1 nums[i] nums i i + 1 i 1 {
				falseCnt++;
			} falseCnt++ falseCnt if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		} falseCnt == 0 || falseCnt == 2 falseCnt == 0 falseCnt 0 falseCnt == 2 falseCnt 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) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int cnt = sc.nextInt();
		int[] nums = new int[cnt];
		for (int i = 0; i < cnt; i++) {
			nums[i] = sc.nextInt();
		}

		int falseCnt = 0;

		for (int i = 0; i < cnt; i++) {
			if (nums[i] != i + 1) {
				falseCnt++;
			}
		}

		if (falseCnt == 0 || falseCnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}
