import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int diff = 0; diff 0 for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            if(i != sc.nextInt()){
                diff++;
            }
        } {
            if(i != sc.nextInt()){
                diff++;
            }
        } if(i != sc.nextInt()){
                diff++;
            } i != sc.nextInt() i sc.nextInt() sc.nextInt sc {
                diff++;
            } diff++ diff System.out.println(diff <= 2 ? "YES" : "NO") System.out.println System.out System System.out diff <= 2 ? "YES" : "NO" diff <= 2 diff 2 "YES" "NO" String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
} Main
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int diff = 0;
        for(int i = 1; i <= n; i++){
            if(i != sc.nextInt()){
                diff++;
            }
        }
        
        System.out.println(diff <= 2 ? "YES" : "NO");
    }
}