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