import java.util.Scanner;

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

		int n = sc.nextInt();
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");

		sc.close();
	}

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

		int n = sc.nextInt();
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");

		sc.close();
	}

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

		int n = sc.nextInt();
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");

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

		int n = sc.nextInt();
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		} {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		} int p = sc.nextInt(); p sc.nextInt() sc.nextInt sc if (p != i)
				cnt++; p != i p i cnt++ cnt System.out.println(cnt <= 2 ? "YES" : "NO") System.out.println System.out System System.out cnt <= 2 ? "YES" : "NO" cnt <= 2 cnt 2 "YES" "NO" sc.close() sc.close sc String[] args args
import java.util.Scanner;

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

		int n = sc.nextInt();
		int cnt = 0;

		for (int i = 1; i <= n; i++) {
			int p = sc.nextInt();
			if (p != i)
				cnt++;
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");

		sc.close();
	}

}
