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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
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);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    }
}
 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.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);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    }
} 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);
        B0Or1Swap solver = new B0Or1Swap();
        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);
        B0Or1Swap solver = new B0Or1Swap();
        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) B0Or1Swap solver = new B0Or1Swap(); solver new B0Or1Swap() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    } B0Or1Swap public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        } solve {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        } int n = in.nextInt(); n in.nextInt() in.nextInt in int a[] = new int[n]; a new int[n] n for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                a[i] = in.nextInt();
            } {
                a[i] = in.nextInt();
            } a[i] = in.nextInt() a[i] a i in.nextInt() in.nextInt in if (check(a, n)) {
                out.println("YES");
                return;
            } check(a, n) check a n {
                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++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            } {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            } for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                } {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                } int temp = a[i]; temp a[i] a i a[i] = a[j] a[i] a i a[j] a j a[j] = temp a[j] a j temp if (check(a, n)) {
                        out.println("YES");
                        return;
                    } check(a, n) check a n {
                        out.println("YES");
                        return;
                    } out.println("YES") out.println out "YES" return; temp = a[i] temp a[i] a i a[i] = a[j] a[i] a i a[j] a j a[j] = temp a[j] a j temp out.println("NO") out.println out "NO" int testNumber testNumber Scanner in in PrintWriter out out boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        } check {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        } for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
                if (a[i] < a[i - 1])
                    return false;
            } {
                if (a[i] < a[i - 1])
                    return false;
            } if (a[i] < a[i - 1])
                    return false; a[i] < a[i - 1] a[i] a i a[i - 1] a i - 1 i 1 return false; false return true; true int a[] a int n n 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);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    }
} 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);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
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);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            if (check(a, n)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                    if (check(a, n)) {
                        out.println("YES");
                        return;
                    }
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
            out.println("NO");
        }

        boolean check(int a[], int n) {
            for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1])
                    return false;
            }
            return true;
        }

    }
}

