import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	} main {
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int cnt = sc.nextInt(); cnt sc.nextInt() sc.nextInt sc int a[]= new int[cnt]; a new int[cnt] cnt int sigcnt =0; sigcnt 0 String answer = "YES"; answer "YES" for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        } int i=0 ; int i=0 ; i 0 i<cnt i cnt i++ i++ i {
         a[i]=sc.nextInt(); 
        } {
         a[i]=sc.nextInt(); 
        } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        } int i=0 ; int i=0 ; i 0 i<cnt i cnt i++ i++ i {
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        } {
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        } if(a[i]!=i+1){
           sigcnt++;
         } a[i]!=i+1 a[i] a i i+1 i 1 {
           sigcnt++;
         } sigcnt++ sigcnt if(sigcnt>2){
           answer="NO";
           break;
         } sigcnt>2 sigcnt 2 {
           answer="NO";
           break;
         } answer="NO" answer "NO" break; System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int cnt = sc.nextInt();
        int a[]= new int[cnt];
        int sigcnt =0;
      String answer = "YES";
        for(int i=0 ; i<cnt ; i++){
         a[i]=sc.nextInt(); 
        }
        for(int i=0 ; i<cnt ; i++){
         if(a[i]!=i+1){
           sigcnt++;
         }
         if(sigcnt>2){
           answer="NO";
           break;
         }
        }

		System.out.println(answer);

	}
}
