import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.nextLine(); N sc.nextLine() sc.nextLine sc String P = sc.nextLine(); P sc.nextLine() sc.nextLine sc String[] PA = P.split(" "); PA P.split(" ") P.split P " " int zure = 0; zure 0 for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		} int i=1; int i=1; i 1 i<=Integer.parseInt(N) i Integer.parseInt(N) Integer.parseInt Integer N i++ i++ i {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		} {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		} if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			} Integer.parseInt(PA[i - 1]) != i Integer.parseInt(PA[i - 1]) Integer.parseInt Integer PA[i - 1] PA i - 1 i 1 i {
				zure++;
			} zure++ zure if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		} zure <= 2 zure 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" sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String P = sc.nextLine();
		String[] PA = P.split(" ");
		int zure = 0;
		
		for(int i=1; i<=Integer.parseInt(N); i++) {
			if(Integer.parseInt(PA[i - 1]) != i) {
				zure++;
			}
		}
		
		if(zure <= 2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();
	}
}