import java.util.Scanner;

class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int all = sc.nextInt();

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

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

    int fault = 0;
    for(int i = 0;i<all;i++){
      if(sc.nextInt() != i+1){
        fault++;
      }
    }
    System.out.println(fault<=2 ? "YES" : "NO" );
  } main {
    Scanner sc = new Scanner(System.in);
    int all = sc.nextInt();

    int fault = 0;
    for(int i = 0;i<all;i++){
      if(sc.nextInt() != i+1){
        fault++;
      }
    }
    System.out.println(fault<=2 ? "YES" : "NO" );
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int all = sc.nextInt(); all sc.nextInt() sc.nextInt sc int fault = 0; fault 0 for(int i = 0;i<all;i++){
      if(sc.nextInt() != i+1){
        fault++;
      }
    } int i = 0; int i = 0; i 0 i<all i all i++ i++ i {
      if(sc.nextInt() != i+1){
        fault++;
      }
    } {
      if(sc.nextInt() != i+1){
        fault++;
      }
    } if(sc.nextInt() != i+1){
        fault++;
      } sc.nextInt() != i+1 sc.nextInt() sc.nextInt sc i+1 i 1 {
        fault++;
      } fault++ fault System.out.println(fault<=2 ? "YES" : "NO" ) System.out.println System.out System System.out fault<=2 ? "YES" : "NO" fault<=2 fault 2 "YES" "NO" String args[] args
import java.util.Scanner;

class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int all = sc.nextInt();

    int fault = 0;
    for(int i = 0;i<all;i++){
      if(sc.nextInt() != i+1){
        fault++;
      }
    }
    System.out.println(fault<=2 ? "YES" : "NO" );
  }
}
    
    
