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;
}
}


}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz