import java.util.*;
  public class Main{
    public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("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 count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("NO");
        }
    }
  } Main public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("NO");
        }
    } main {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("NO");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int count = 0; count 0 int [] data = new int[50]; data new int[50] 50 for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
        data[i] = sc.nextInt();
      } {
        data[i] = sc.nextInt();
      } data[i] = sc.nextInt() data[i] data i sc.nextInt() sc.nextInt sc for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      } int k = 0; int k = 0; k 0 k<N k N k++ k++ k {
        if(data[k] != k+1){
          count++;
        }
      } {
        if(data[k] != k+1){
          count++;
        }
      } if(data[k] != k+1){
          count++;
        } data[k] != k+1 data[k] data k k+1 k 1 {
          count++;
        } count++ count if(count<=2){
          System.out.println("YES");
        } count<=2 count 2 {
          System.out.println("YES");
        } System.out.println("YES") System.out.println System.out System System.out "YES" if(count>2){
          System.out.println("NO");
        } count>2 count 2 {
          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){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int count = 0;
      int [] data = new int[50];

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

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("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 count = 0;
      int [] data = new int[50];

      for(int i = 0;i<N;i++){
        data[i] = sc.nextInt();
      }
      
      for(int k = 0;k<N;k++){
        if(data[k] != k+1){
          count++;
        }
      }
        if(count<=2){
          System.out.println("YES");
        }
        if(count>2){
          System.out.println("NO");
        }
    }
  }
