import java.util.*;

public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    }
} import java.util.*; util.* java public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    }
} Main int count = 0; count 0 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			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[] a = new int[n]; a new int[n] n for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
			a[i] = sc.nextInt();
		} {
			a[i] = sc.nextInt();
		} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		} sort(a) < 2 sort(a) sort a 2 {
			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" String[] args args public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    } sort {
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    } int count = 0; count 0 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;
                count++;
            }
        } 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;
                count++;
            }
        } {
            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;
                count++;
            }
        } 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;
                count++;
            } i != index i index {
                int tmp = array[index];
                array[index] = array[i];
                array[i] = tmp;
                count++;
            } 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 count++ count return count; count int[] array array public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    }
} public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    }
} Main
import java.util.*;

public class Main {
	int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		if(sort(a) < 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
	
	public static int sort(int[] array){
		int count = 0;
        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;
                count++;
            }
        }
        return count;
    }
}
