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

public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
} Main public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	} solution {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	} int store1[] = new int[2]; store1 new int[2] 2 int k=0; k 0 int temp [] = new int[arr.length]; temp new int[arr.length] arr.length arr arr.length for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		} int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
			temp[i] = arr[i];
		} {
			temp[i] = arr[i];
		} temp[i] = arr[i] temp[i] temp i arr[i] arr i Arrays.sort(temp) Arrays.sort Arrays temp if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		} Arrays.equals(temp, arr) Arrays.equals Arrays temp arr {
			System.out.println("YES");
			return;
		} System.out.println("YES") System.out.println System.out System System.out "YES" return; for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		} int i=0; int i=0; i 0 i<arr.length-1 i arr.length-1 arr.length arr arr.length 1 i++ i++ i {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		} {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		} if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			} arr[i]>arr[i+1] arr[i] arr i arr[i+1] arr i+1 i 1 {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			} store1[k]=i store1[k] store1 k i k++ k if(k==2) {
					break;
				} k==2 k 2 {
					break;
				} break; store1[1]++ store1[1] store1 1 int temp1 = arr[store1[0]]; temp1 arr[store1[0]] arr store1[0] store1 0 arr[store1[0]] = arr[store1[1]] arr[store1[0]] arr store1[0] store1 0 arr[store1[1]] arr store1[1] store1 1 arr[store1[1]] = temp1 arr[store1[1]] arr store1[1] store1 1 temp1 if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		} Arrays.equals(arr, temp) Arrays.equals Arrays arr temp {
			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" int [] arr arr public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	} main {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	} Scanner obj = new Scanner(System.in); obj new Scanner(System.in) int n = obj.nextInt(); n obj.nextInt() obj.nextInt obj int a [] = new int [n]; a new int [n] n for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		} int i=0; int i=0; i 0 i<a.length i a.length a a.length i++ i++ i {
			a[i]= obj.nextInt();
		} {
			a[i]= obj.nextInt();
		} a[i]= obj.nextInt() a[i] a i obj.nextInt() obj.nextInt obj solution(a) solution a String args [] args public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
} public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
}
