import java.io.*;
import java.util.ArrayList;
//password:53VHEnd4
public class Main{
  public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
public static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
}


} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util public class Main{
  public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
public static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
}


} Main public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  } main {
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  } String str; str try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    } catch(IOException e){
      e.printStackTrace();
    } IOException e {
      e.printStackTrace();
    } e.printStackTrace() e.printStackTrace e {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    } BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8")); br new BufferedReader(new InputStreamReader(System.in,"UTF-8")) str=br.readLine() str br.readLine() br.readLine br int length=Integer.parseInt(str); length Integer.parseInt(str) Integer.parseInt Integer str str=br.readLine() str br.readLine() br.readLine br String[] arraystr = str.split(" "); arraystr str.split(" ") str.split str " " int[] num=new int[length]; num new int[length] length for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      } int i=0; int i=0; i 0 i<length i length i++ i++ i {
        num[i]=Integer.parseInt(arraystr[i]);
      } {
        num[i]=Integer.parseInt(arraystr[i]);
      } num[i]=Integer.parseInt(arraystr[i]) num[i] num i Integer.parseInt(arraystr[i]) Integer.parseInt Integer arraystr[i] arraystr i int ans=check(num); ans check(num) check num if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    } ans==0 ans 0 {
        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 static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
} check {
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
} int p=0; p 0 for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  } int i=1; int i=1; i 1 i<num.length i num.length num num.length i++ i++ i {
    if(num[i-1]!=i){
      p+=1;
    }
  } {
    if(num[i-1]!=i){
      p+=1;
    }
  } if(num[i-1]!=i){
      p+=1;
    } num[i-1]!=i num[i-1] num i-1 i 1 i {
      p+=1;
    } p+=1 p 1 if(p>2){
    return 0;
  }else{
  return 1;
} p>2 p 2 {
    return 0;
  } return 0; 0 {
  return 1;
} return 1; 1 int[] num num public class Main{
  public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
public static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
}


} public class Main{
  public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
public static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
}


} Main
import java.io.*;
import java.util.ArrayList;
//password:53VHEnd4
public class Main{
  public static void main(String args[]){
    String str;
    try{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in,"UTF-8"));
      str=br.readLine();
      int length=Integer.parseInt(str);
            str=br.readLine();
      String[] arraystr = str.split(" ");
      int[] num=new int[length];
      for(int i=0;i<length;i++){
        num[i]=Integer.parseInt(arraystr[i]);
      }
      int ans=check(num);
      if(ans==0){
        System.out.println("NO");
      }else{
      System.out.println("YES");
    }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
public static int check(int[] num){
  int p=0;
  for(int i=1;i<num.length;i++){
    if(num[i-1]!=i){
      p+=1;
    }
  }
  if(p>2){
    return 0;
  }else{
  return 1;
}
}


}
