import java.util.*;

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

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