import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] p = new int[N]; p new int[N] N for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            p[i] = sc.nextInt();
        } {
            p[i] = sc.nextInt();
        } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc boolean result = check(p); result check(p) check p if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        } !result result {
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        } for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            } int i=0; int i=0; i 0 i<N i N i++ i++ i {
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            } {
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            } for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                } int j=0; int j=0; j 0 j<N j N j++ j++ j {
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                } {
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                } if(i == j) break; i == j i j break; int[] list = p.clone(); list p.clone() p.clone p int tmp = list[i]; tmp list[i] list i list[i] = list[j] list[i] list i list[j] list j list[j] = tmp list[j] list j tmp if(check(list)){
                        result = true;
                        break;
                    } check(list) check list {
                        result = true;
                        break;
                    } result = true result true break; System.out.println(result ? "YES" : "NO") System.out.println System.out System System.out result ? "YES" : "NO" result "YES" "NO" String[] args args public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    } check {
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    } boolean result = true; result true for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        } int i=0; int i=0; i 0 i<list.length-1 i list.length-1 list.length list list.length 1 i++ i++ i {
            if(list[i] > list[i+1]){
                result = false;
            }
        } {
            if(list[i] > list[i+1]){
                result = false;
            }
        } if(list[i] > list[i+1]){
                result = false;
            } list[i] > list[i+1] list[i] list i list[i+1] list i+1 i 1 {
                result = false;
            } result = false result false return result; result int[] list list public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
        }

        boolean result = check(p);

        if(!result){
            for(int i=0; i<N; i++){
                for(int j=0; j<N; j++){
                    if(i == j) break;
                    int[] list = p.clone();

                    int tmp = list[i];
                    list[i] = list[j];
                    list[j] = tmp;
                    if(check(list)){
                        result = true;
                        break;
                    }
                }
            }
        }

        System.out.println(result ? "YES" : "NO");

    }

    public static boolean check(int[] list){
        boolean result = true;

        for(int i=0; i<list.length-1; i++){
            if(list[i] > list[i+1]){
                result = false;
            }
        }

        return result;
    }
}