import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    } main {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int t = scan.nextInt(); t scan.nextInt() scan.nextInt scan int[] array = new int[t]; array new int[t] t int[] copy = new int[t]; copy new int[t] t for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        } int count = 0; int count = 0; count 0 count < t count t count++ count++ count {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        } {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        } int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan array[count] = n array[count] array count n copy[count] = n copy[count] copy count n scan.close() scan.close scan Arrays.sort(copy) Arrays.sort Arrays copy int counter = 0; counter 0 for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        } int count = 0; int count = 0; count 0 count < t count t count++ count++ count {
            if(array[count] != copy[count]) {
                counter++;
            }
        } {
            if(array[count] != copy[count]) {
                counter++;
            }
        } if(array[count] != copy[count]) {
                counter++;
            } array[count] != copy[count] array[count] array count copy[count] copy count {
                counter++;
            } counter++ counter if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO"); counter < 3 counter 3 {
            System.out.println("YES");
        } 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 scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

} public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

}