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