import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) boolean flg = true; flg true int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int array[] = new int[n]; array new int[n] n int flg2 = -1; flg2 -1 1 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 for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		} {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		} if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			} flg2 != -1 && array[i-1] > array[i] flg2 != -1 flg2 -1 1 array[i-1] > array[i] array[i-1] array i-1 i 1 array[i] array i {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			} int tmp = array[flg2]; tmp array[flg2] array flg2 array[flg2] = array[i] array[flg2] array flg2 array[i] array i array[i] = tmp array[i] array i tmp flg2 = -1 flg2 -1 1 break; if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			} i > 0 && flg2 == -1 && array[i-1] > array[i] i > 0 && flg2 == -1 && array[i-1] > array[i] i > 0 i 0 flg2 == -1 flg2 -1 1 array[i-1] > array[i] array[i-1] array i-1 i 1 array[i] array i {
				flg2 = i-1;
			} flg2 = i-1 flg2 i-1 i 1 if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		} flg2 != -1 flg2 -1 1 {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		} int tmp = array[flg2+1]; tmp array[flg2+1] array flg2+1 flg2 1 array[flg2+1] = array[flg2] array[flg2+1] array flg2+1 flg2 1 array[flg2] array flg2 array[flg2] = tmp array[flg2] array flg2 tmp for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		} int i = 0; int i = 0; i 0 i < n-1 i n-1 n 1 i++ i++ i {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		} {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		} if(array[i] > array[i+1]) {
				flg = false;
				break;
			} array[i] > array[i+1] array[i] array i array[i+1] array i+1 i 1 {
				flg = false;
				break;
			} flg = false flg false break; if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		} flg {
			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" sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean flg = true;

		// 整数の入力
		int n = sc.nextInt();

		int array[] = new int[n];

		int flg2 = -1;
		
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			//array[i] = sc.nextInt();
			
			if(flg2 != -1 && array[i-1] > array[i]) {
				int tmp = array[flg2];
				array[flg2] = array[i];
				array[i] = tmp;
				
				flg2 = -1;
				break;
			}
			
			if(i > 0 && flg2 == -1 && array[i-1] > array[i]) {
				flg2 = i-1;
			}
		}
		
		if(flg2 != -1) {
			int tmp = array[flg2+1];
			array[flg2+1] = array[flg2];
			array[flg2] = tmp;
		}
		
		for(int i = 0; i < n-1; i++) {
			if(array[i] > array[i+1]) {
				flg = false;
				break;
			}
		}

		if(flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

        sc.close();
	}
}