import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) ABC135_b solver = new ABC135_b(); solver new ABC135_b() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    } ABC135_b public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        } solve {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        } int N = in.nextInt(); N in.nextInt() in.nextInt in int[] p = new int[N]; p new int[N] N int[] p_sorted = new int[N]; p_sorted new int[N] N int wk = 0; wk 0 for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            } {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            } p[i] = in.nextInt() p[i] p i in.nextInt() in.nextInt in p_sorted[i] = p[i] p_sorted[i] p_sorted i p[i] p i Arrays.sort(p_sorted) Arrays.sort Arrays p_sorted if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            } Arrays.equals(p, p_sorted) Arrays.equals Arrays p p_sorted {
                out.println("YES");
                return;
            } out.println("YES") out.println out "YES" return; for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            } {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            } for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                } int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                } {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                } wk = p[j] wk p[j] p j p[j] = p[i] p[j] p j p[i] p i p[i] = wk p[i] p i wk if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    } Arrays.equals(p, p_sorted) Arrays.equals Arrays p p_sorted {
                        out.println("YES");
                        return;
                    } out.println("YES") out.println out "YES" return; p[i] = p[j] p[i] p i p[j] p j p[j] = wk p[j] p j wk out.println("NO") out.println out "NO" int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC135_b solver = new ABC135_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC135_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] p = new int[N];
            int[] p_sorted = new int[N];

            int wk = 0;
            for (int i = 0; i < N; i++) {
                //if (i == 0) {
                //    p[i] = 0;
                //    p_sorted[i] = 0;
                //} else {
                p[i] = in.nextInt();
                p_sorted[i] = p[i];
                //}
            }
            Arrays.sort(p_sorted);
            if (Arrays.equals(p, p_sorted)) {
                out.println("YES");
                return;
            }
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    wk = p[j];
                    p[j] = p[i];
                    p[i] = wk;

                    if (Arrays.equals(p, p_sorted)) {
                        out.println("YES");
                        return;
                    }
                    p[i] = p[j];
                    p[j] = wk;

                }
            }
            out.println("NO");
        }

    }
}

