import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

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

} 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 count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

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

} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

		System.out.println(count <= 2? "YES": "NO");
	} main {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

		System.out.println(count <= 2? "YES": "NO");
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int count = 0; count 0 for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		} int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		} {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		} int p = scan.nextInt(); p scan.nextInt() scan.nextInt scan if(p != i) {
				count++;
			} p != i p i {
				count++;
			} count++ count System.out.println(count <= 2? "YES": "NO") System.out.println System.out System System.out count <= 2? "YES": "NO" count <= 2 count 2 "YES" "NO" String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

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

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

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

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int count = 0;

		for(int i = 1; i <= N; i++) {
			int p = scan.nextInt();
			if(p != i) {
				count++;
			}
		}

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

}