import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] s = new int[n]; s new int[n] n int[] c = new int[n]; c new int[n] n int counter = 0; counter 0 for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        } int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
            s[i] = scan.nextInt();
            c[i] = s[i];
        } {
            s[i] = scan.nextInt();
            c[i] = s[i];
        } s[i] = scan.nextInt() s[i] s i scan.nextInt() scan.nextInt scan c[i] = s[i] c[i] c i s[i] s i Arrays.sort(c) Arrays.sort Arrays c for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
            if(c[j] == s[j]){
                counter++;
            }
        } {
            if(c[j] == s[j]){
                counter++;
            }
        } if(c[j] == s[j]){
                counter++;
            } c[j] == s[j] c[j] c j s[j] s j {
                counter++;
            } counter++ counter System.out.print((counter>=n-2 ? "YES" : "NO")) System.out.print System.out System System.out (counter>=n-2 ? "YES" : "NO") counter>=n-2 counter n-2 n 2 "YES" "NO" scan.close() scan.close scan String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    }
} Main
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = scan.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] == s[j]){
                counter++;
            }
        }
        System.out.print((counter>=n-2 ? "YES" : "NO"));
        scan.close();
    }
}