import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
		int[] p=new int[n];
  		int d=0;
		for(int c=0;c<n;c++){
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	}
  		
  
 	if(d<=2){
    		System.out.println("YES");
    	}else{
     		System.out.println("NO");
   	 }

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

    	
    } main {
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
		int[] p=new int[n];
  		int d=0;
		for(int c=0;c<n;c++){
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	}
  		
  
 	if(d<=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[] p=new int[n]; p new int[n] n int d=0; d 0 for(int c=0;c<n;c++){
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	} int c=0; int c=0; c 0 c<n c n c++ c++ c {
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	} {
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	} p[c]=sc.nextInt() p[c] p c sc.nextInt() sc.nextInt sc if(p[c]!=c+1){
            	d++;
            } p[c]!=c+1 p[c] p c c+1 c 1 {
            	d++;
            } d++ d if(d<=2){
    		System.out.println("YES");
    	}else{
     		System.out.println("NO");
   	 } d<=2 d 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
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
		int[] p=new int[n];
  		int d=0;
		for(int c=0;c<n;c++){
    		p[c]=sc.nextInt();
          	if(p[c]!=c+1){
            	d++;
            }
              
    	}
  		
  
 	if(d<=2){
    		System.out.println("YES");
    	}else{
     		System.out.println("NO");
   	 }

    	
    }
}
