import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main{
	
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	}
} Main public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	} main {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	} Scanner scn=new Scanner(System.in); scn new Scanner(System.in) ArrayList<Integer> list=new ArrayList<>(); list new ArrayList<>() ArrayList<Integer> list1=new ArrayList<>(); list1 new ArrayList<>() int t=scn.nextInt(); t scn.nextInt() scn.nextInt scn for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		} int i=0; int i=0; i 0 i<t i t i++ i++ i {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		} {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		} int x=scn.nextInt(); x scn.nextInt() scn.nextInt scn list.add(x) list.add list x list1.add(x) list1.add list1 x Collections.sort(list) Collections.sort Collections list int count=0; count 0 for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		} int i=0; int i=0; i 0 i<list.size() i list.size() list.size list i++ i++ i {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		} {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		} if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			} list.get(i)!=list1.get(i) list.get(i) list.get list i list1.get(i) list1.get list1 i {
				count++;
				if(count>3) {
					break;
				}
			} count++ count if(count>3) {
					break;
				} count>3 count 3 {
					break;
				} break; if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		} count<3 count 3 {
			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" scn.close() scn.close scn String[] args args public class Main{
	
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	}
} public class Main{
	
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner scn=new Scanner(System.in);
		ArrayList<Integer> list=new ArrayList<>();
		ArrayList<Integer> list1=new ArrayList<>();
		
		int t=scn.nextInt();
		
		for(int i=0;i<t;i++) {
			int x=scn.nextInt();
			
			list.add(x);
			list1.add(x);
		}
		Collections.sort(list);
		
		int count=0;
		for(int i=0;i<list.size();i++) {
			
			if(list.get(i)!=list1.get(i)) {
				count++;
				if(count>3) {
					break;
				}
			}		
		}
		if(count<3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		scn.close();
	}
}