import java.io.*;
import java.util.*;

public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   }
} Main public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   } main {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int[] arr = new int[sc.nextInt()]; arr new int[sc.nextInt()] sc.nextInt() sc.nextInt sc int wrong = 0; wrong 0 for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        } {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc if (arr[i] != i + 1) {
             	wrong++; 
            } arr[i] != i + 1 arr[i] arr i i + 1 i 1 {
             	wrong++; 
            } wrong++ wrong out.println(wrong == 2 || wrong == 0 ? "YES" : "NO") out.println out wrong == 2 || wrong == 0 ? "YES" : "NO" wrong == 2 || wrong == 0 wrong == 2 wrong 2 wrong == 0 wrong 0 "YES" "NO" out.close() out.close out String[] args args public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   }
} public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   }
} Main
import java.io.*;
import java.util.*;

public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 || wrong == 0 ? "YES" : "NO");
      	out.close();
   }
}