import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	}
	
	private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	}
	private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	}
	
	private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	}
} import java.io.IOException; IOException java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	}
	
	private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	}
	private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	}
	
	private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	}
} Main public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	} main {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	} Scanner sn = new Scanner(System.in); sn new Scanner(System.in) Integer N = Integer.parseInt(sn.nextLine()); N Integer.parseInt(sn.nextLine()) Integer.parseInt Integer sn.nextLine() sn.nextLine sn String[] PsStr = sn.nextLine().split(" "); PsStr sn.nextLine().split(" ") sn.nextLine().split sn.nextLine() sn.nextLine sn " " Integer[] Ps = conv(PsStr, N); Ps conv(PsStr, N) conv PsStr N Integer[] sorted = Arrays.copyOf(Ps, N); sorted Arrays.copyOf(Ps, N) Arrays.copyOf Arrays Ps N Arrays.sort(sorted) Arrays.sort Arrays sorted if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		} comp(Ps, sorted) == 0 comp(Ps, sorted) comp Ps sorted 0 {
			System.out.println("YES");
			return;
		} System.out.println("YES") System.out.println System.out System System.out "YES" return; int srcIndex = -1; srcIndex -1 1 int toIndex = -1; toIndex -1 1 for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		} int i = 0; int i = 0; i 0 i < Ps.length i Ps.length Ps Ps.length i++ i++ i {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		} {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		} if (Ps[i].equals(sorted[i])) {
				continue;
			} Ps[i].equals(sorted[i]) Ps[i].equals Ps[i] Ps i sorted[i] sorted i {
				continue;
			} continue; srcIndex = i srcIndex i toIndex = getToIndex(Ps[i], sorted) toIndex getToIndex(Ps[i], sorted) getToIndex Ps[i] Ps i sorted break; int src = Ps[toIndex]; src Ps[toIndex] Ps toIndex int to = Ps[srcIndex]; to Ps[srcIndex] Ps srcIndex Ps[srcIndex] = src Ps[srcIndex] Ps srcIndex src Ps[toIndex] = to Ps[toIndex] Ps toIndex to System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO")) System.out.println System.out System System.out (comp(Ps, sorted) == 0 ? "YES" : "NO") comp(Ps, sorted) == 0 comp(Ps, sorted) comp Ps sorted 0 "YES" "NO" String[] args args private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	} conv {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	} Integer[] Ps = new Integer[N]; Ps new Integer[N] N for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		} int i = 0; int i = 0; i 0 i < PsStr.length i PsStr.length PsStr PsStr.length i++ i++ i {
			Ps[i] = Integer.parseInt(PsStr[i]);
		} {
			Ps[i] = Integer.parseInt(PsStr[i]);
		} Ps[i] = Integer.parseInt(PsStr[i]) Ps[i] Ps i Integer.parseInt(PsStr[i]) Integer.parseInt Integer PsStr[i] PsStr i return Ps; Ps String[] PsStr PsStr int N N private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	} comp {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	} for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		} int i = 0; int i = 0; i 0 i < Ps.length i Ps.length Ps Ps.length i++ i++ i {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		} {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		} if (Ps[i] != sorted[i]) {
				return -1;
			} Ps[i] != sorted[i] Ps[i] Ps i sorted[i] sorted i {
				return -1;
			} return -1; -1 1 return 0; 0 Integer[] Ps Ps Integer[] sorted sorted private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	} getToIndex {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	} for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		} int i = 0; int i = 0; i 0 i < sorted.length i sorted.length sorted sorted.length i++ i++ i {
			if (sorted[i] == p) {
				return i;
			}
		} {
			if (sorted[i] == p) {
				return i;
			}
		} if (sorted[i] == p) {
				return i;
			} sorted[i] == p sorted[i] sorted i p {
				return i;
			} return i; i return -1; -1 1 Integer p p Integer[] sorted sorted public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	}
	
	private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	}
	private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	}
	
	private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	}
	
	private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	}
	private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	}
	
	private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	}
} Main
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		Integer N = Integer.parseInt(sn.nextLine());
		String[] PsStr = sn.nextLine().split(" ");
		Integer[] Ps = conv(PsStr, N);
		Integer[] sorted = Arrays.copyOf(Ps, N);
		Arrays.sort(sorted);
		
		if (comp(Ps, sorted) == 0) {
			System.out.println("YES");
			return;
		}
		
		int srcIndex = -1;
		int toIndex = -1;
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i].equals(sorted[i])) {
				continue;
			}
			srcIndex = i;
			toIndex = getToIndex(Ps[i], sorted);
			break;
		}
		
		int src = Ps[toIndex];
		int to = Ps[srcIndex];
		
		Ps[srcIndex] = src;
		Ps[toIndex] = to;
		
		System.out.println((comp(Ps, sorted) == 0 ? "YES" : "NO"));
	}
	
	private static Integer[] conv(String[] PsStr, int N) {
		Integer[] Ps = new Integer[N];
		for (int i = 0; i < PsStr.length; i++) {
			Ps[i] = Integer.parseInt(PsStr[i]);
		}
		return Ps;
	}
	private static int comp(Integer[] Ps, Integer[] sorted) {
		for (int i = 0; i < Ps.length; i++) {
			if (Ps[i] != sorted[i]) {
				return -1;
			}
		}
		return 0;
	}
	
	private static int getToIndex(Integer p, Integer[] sorted) {
		for (int i = 0; i < sorted.length; i++) {
			if (sorted[i] == p) {
				return i;
			}
		}
		return -1;
	}
}