import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
}} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
}} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
} main {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		} {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		} if (sc.nextInt() != i+1) {
				cnt += 1;
			} sc.nextInt() != i+1 sc.nextInt() sc.nextInt sc i+1 i 1 {
				cnt += 1;
			} cnt += 1 cnt 1 if (cnt > 2) {
				break;
			} cnt > 2 cnt 2 {
				break;
			} break; if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		} cnt > 2 cnt 2 {
			System.out.println("NO");
		} System.out.println("NO") System.out.println System.out System System.out "NO" {
			System.out.println("YES");
		} 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 sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
}} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
}} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		
		for (int i = 0; i<n; i++) {
			if (sc.nextInt() != i+1) {
				cnt += 1;
			}
			if (cnt > 2) {
				break;
			}
		}

		if (cnt > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
}}