import java.util.Scanner;

public class Main {

    void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}
 import java.util.Scanner; Scanner java.util public class Main {

    void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
} Main void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    } solve {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("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 if (isOK(p)) {
            System.out.println("YES");
            return;
        } isOK(p) isOK p {
            System.out.println("YES");
            return;
        } System.out.println("YES") System.out.println System.out System System.out "YES" return; for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        } int i = 0; int i = 0; i 0 i <= N - 2 i N - 2 N 2 i++ i++ i {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        } {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        } for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j <= N - 1 j N - 1 N 1 j++ j++ j {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            } {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            } int[] pClone = p.clone(); pClone p.clone() p.clone p int tmp = pClone[i]; tmp pClone[i] pClone i pClone[i] = pClone[j] pClone[i] pClone i pClone[j] pClone j pClone[j] = tmp pClone[j] pClone j tmp if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                } isOK((pClone)) isOK (pClone) {
                    System.out.println("YES");
                    return;
                } System.out.println("YES") System.out.println System.out System System.out "YES" return; System.out.println("NO") System.out.println System.out System System.out "NO" boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    } isOK {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    } for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        } int i = 0; int i = 0; i 0 i <= array.length - 2 i array.length - 2 array.length array array.length 2 i++ i++ i {
            if (array[i] > array[i + 1]) {
                return false;
            }
        } {
            if (array[i] > array[i + 1]) {
                return false;
            }
        } if (array[i] > array[i + 1]) {
                return false;
            } array[i] > array[i + 1] array[i] array i array[i + 1] array i + 1 i 1 {
                return false;
            } return false; false return true; true int[] array array // Main
    public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args public class Main {

    void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
} public class Main {

    void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
} Main
import java.util.Scanner;

public class Main {

    void solve() {
        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();
        }
        if (isOK(p)) {
            System.out.println("YES");
            return;
        }
        for (int i = 0; i <= N - 2; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                int[] pClone = p.clone();
                int tmp = pClone[i];
                pClone[i] = pClone[j];
                pClone[j] = tmp;
                if (isOK((pClone))) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    boolean isOK (int[] array) {
        for (int i = 0; i <= array.length - 2; i++) {
            if (array[i] > array[i + 1]) {
                return false;
            }
        }
        return true;
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

