import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	} main {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan int[] ar = new int[num]; ar new int[num] num for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i<num i num i++ i++ i {
			ar[i] = scan.nextInt();
		} {
			ar[i] = scan.nextInt();
		} ar[i] = scan.nextInt() ar[i] ar i scan.nextInt() scan.nextInt scan int[] e = new int[2]; e new int[2] 2 int[] log = new int[2]; log new int[2] 2 int k = 0; k 0 for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		} int j = 0; int j = 0; j 0 j<num-1 j num-1 num 1 j++ j++ j {
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		} {
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		} if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			} ar[j+1]<ar[j]&&k!=1 ar[j+1]<ar[j] ar[j+1] ar j+1 j 1 ar[j] ar j k!=1 k 1 {
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			} e[0]=ar[j] e[0] e 0 ar[j] ar j log[0]=j log[0] log 0 j j=0 j 0 k++ k if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			} ar[j+1]<ar[j]&&k==1&&j!=log[0] ar[j+1]<ar[j]&&k==1&&j!=log[0] ar[j+1]<ar[j] ar[j+1] ar j+1 j 1 ar[j] ar j k==1 k 1 j!=log[0] j log[0] log 0 {
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			} e[1]=ar[j+1] e[1] e 1 ar[j+1] ar j+1 j 1 log[1]=j+1 log[1] log 1 j+1 j 1 break; if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	} k==1 k 1 {
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	} ar[log[0]]=e[1] ar[log[0]] ar log[0] log 0 e[1] e 1 ar[log[1]]=e[0] ar[log[1]] ar log[1] log 1 e[0] e 0 for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		} int l = 0; int l = 0; l 0 l<num-1 l num-1 num 1 l++ l++ l {
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		} {
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		} if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			} ar[l+1]<ar[l] ar[l+1] ar l+1 l 1 ar[l] ar l {
				System.out.println("NO");
				System.exit(0);
			} System.out.println("NO") System.out.println System.out System System.out "NO" System.exit(0) System.exit System 0 System.out.println("YES") System.out.println System.out System System.out "YES" String[] args args public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
} public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] ar = new int[num];
		for(int i = 0;i<num;i++){
			ar[i] = scan.nextInt();
		}
		int[] e = new int[2];
		int[] log = new int[2];
		int k = 0;
		for(int j = 0;j<num-1;j++){
			if(ar[j+1]<ar[j]&&k!=1){
				e[0]=ar[j];
				log[0]=j;
				j=0;
				k++;
				// System.out.println(e[0]+" "+log[0]);
			}else if(ar[j+1]<ar[j]&&k==1&&j!=log[0]){
				e[1]=ar[j+1];
				log[1]=j+1;
				// System.out.println(e[1]+" "+log[1]);
				break;

			}
		}
		if(k==1){
		ar[log[0]]=e[1];
		ar[log[1]]=e[0];
	}
		for(int l = 0;l<num-1;l++){
			if(ar[l+1]<ar[l]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
}