import java.util.Scanner;

public class Main {
    public int sortNum = 0;

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public int sortNum = 0;

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
} Main public int sortNum = 0; sortNum 0 public static void main(String[] args) {
        Main main = new Main();
        main.start();
    } main {
        Main main = new Main();
        main.start();
    } Main main = new Main(); main new Main() main.start() main.start main String[] args args public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    } start {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            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[] array = new int[n]; array new int[n] n for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            array[i] = sc.nextInt();
        } {
            array[i] = sc.nextInt();
        } array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc sort(array) sort array if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        } sortNum <= 1 sortNum 1 {
            System.out.println("YES");
        } System.out.println("YES") System.out.println System.out System System.out "YES" {
            System.out.println("NO");
        } System.out.println("NO") System.out.println System.out System System.out "NO" public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    } sort {
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    } for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        } int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        } {
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        } int index = i; index i for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j < array.length j array.length array array.length j++ j++ j {
                if(array[j] < array[index]){
                    index = j;
                }
            } {
                if(array[j] < array[index]){
                    index = j;
                }
            } if(array[j] < array[index]){
                    index = j;
                } array[j] < array[index] array[j] array j array[index] array index {
                    index = j;
                } index = j index j if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            } i != index i index {
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            } int tmp = array[index]; tmp array[index] array index array[index] = array[i] array[index] array index array[i] array i array[i] = tmp array[i] array i tmp sortNum++ sortNum int[] array array public class Main {
    public int sortNum = 0;

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
} public class Main {
    public int sortNum = 0;

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public int sortNum = 0;

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

    public void start(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = sc.nextInt();
        }
        sort(array);

        if(sortNum <= 1){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public void sort(int[] array){
        for(int i = 0; i < array.length; i++ ){
            int index = i;
            for(int j = i + 1; j < array.length; j++){
                if(array[j] < array[index]){
                    index = j;
                }
            }
            if(i != index){
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                sortNum++;
            }
        }
    }
}
