import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

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

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int length = sc.nextInt(); length sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		} int i = 1; int i = 1; i 1 i <= length i length i++ i++ i {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		} {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		} cnt += (sc.nextInt() != i) ? 1 : 0 cnt (sc.nextInt() != i) ? 1 : 0 (sc.nextInt() != i) sc.nextInt() sc.nextInt sc i 1 0 if(cnt >= 3) {
				break;
			} cnt >= 3 cnt 3 {
				break;
			} break; 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" String args[] args public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	}
} public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

		System.out.println(cnt <= 2 ? "YES" : "NO");
	}
} Main
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

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

		for(int i = 1; i <= length;i++) {
			cnt += (sc.nextInt() != i) ? 1 : 0;
			if(cnt >= 3) {
				break;
			}
		}

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