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

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
} 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 sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	} main {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) sc.nextLine() sc.nextLine sc String[] line = sc.nextLine().split(" "); line sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " ArrayList<Integer> inputRowList = new ArrayList(); inputRowList new ArrayList() for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		} int i = 0; int i = 0; i 0 i<line.length i line.length line line.length i++ i++ i {
			inputRowList.add(Integer.parseInt(line[i]));
		} {
			inputRowList.add(Integer.parseInt(line[i]));
		} inputRowList.add(Integer.parseInt(line[i])) inputRowList.add inputRowList Integer.parseInt(line[i]) Integer.parseInt Integer line[i] line i ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone(); orderedList (ArrayList<Integer>) inputRowList.clone() inputRowList.clone inputRowList Collections.sort(orderedList) Collections.sort Collections orderedList int count = 0; count 0 for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i<inputRowList.size() i inputRowList.size() inputRowList.size inputRowList i++ i++ i {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		} {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		} if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			} inputRowList.get(i) != orderedList.get(i) inputRowList.get(i) inputRowList.get inputRowList i orderedList.get(i) orderedList.get orderedList i {
				count++;
			} count++ count String result = ""; result "" if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		} count <= 2 count 2 {
			result = "YES";
		} result = "YES" result "YES" {
			result = "NO";
		} result = "NO" result "NO" System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
} public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] line = sc.nextLine().split(" ");
		
		ArrayList<Integer> inputRowList = new ArrayList();
		for(int i = 0;i<line.length;i++) {
			inputRowList.add(Integer.parseInt(line[i]));
		}
		
		ArrayList<Integer> orderedList = (ArrayList<Integer>) inputRowList.clone();
		Collections.sort(orderedList);
		
		int count = 0;
		for(int i = 0;i<inputRowList.size();i++) {
			if(inputRowList.get(i) != orderedList.get(i)) {
				count++;
			}
		}
		
		String result = "";
		if(count <= 2) {
			result = "YES";
		}else {
			result = "NO";
		}
		System.out.println(result);
		
		
		
	}
}