import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
} 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;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] a; a a = new int[N] a new int[N] N int b = 0; b 0 for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    } {     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc if (a[i]==i+1){
      }else{
          b += 1;
      } a[i]==i+1 a[i] a i i+1 i 1 {
      } {
          b += 1;
      } b += 1 b 1 if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    } b>2 b 2 {
      System.out.println("NO");
    } System.out.println("NO") System.out.println System.out System System.out "NO" {
      System.out.println("YES");
    } System.out.println("YES") System.out.println System.out System System.out "YES" String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();  
    int[] a;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
} 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;
    a = new int[N];
    int b = 0;
    
    for (int i = 0; i < N; i++){     
      a[i]=sc.nextInt();
      
      if (a[i]==i+1){
      }else{
          b += 1;
      }
    }
    
    if (b>2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
}