import java.util.Scanner;

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

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[55];
        for(int i = 1; i <= n; ++i){
            a[i] = input.nextInt();
        }
        int[][] b = new int[55][2];
        int sum = 0;
        for(int i = 1; i <= n; ++i){
            if(a[i] != i){
                b[sum][0] = i;
                b[sum][1] = a[i];
                sum++;
            }
        }
        if(sum <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
}
