import java.util.Scanner;

public class Main {
	  public static void main(String[] args ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			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 ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
} Main public static void main(String[] args ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	} main {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int[] array = new int[A]; array new int[A] A int count = 0; count 0 for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		} int i = 0; int i = 0; i 0 i < A i A i++ i++ i {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		} {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		} array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			} array[i] != i+1 array[i] array i i+1 i 1 {
				count ++;
				if (count >= 3) {
					break;
				}
			} count ++ count if (count >= 3) {
					break;
				} count >= 3 count 3 {
					break;
				} break; if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		} count < 3 count 3 {
			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 ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
} public class Main {
	  public static void main(String[] args ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
} Main
import java.util.Scanner;

public class Main {
	  public static void main(String[] args ) throws Exception {
		Scanner sc = new Scanner(System.in);
	
		int A = sc.nextInt();
		int[] array = new int[A];
		int count = 0;
		
		for (int i = 0;i < A; i++) {
			array[i] = sc.nextInt();
			if(array[i] != i+1) {
				count ++;
				if (count >= 3) {
					break;
				}
			}
		}
		if(count < 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}