import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

} Main public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	} main {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	} Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in))); reader new Scanner(new BufferedReader(new InputStreamReader(System.in))) int n n dato dato error=0; error 0 n = reader.nextInt() n reader.nextInt() reader.nextInt reader for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		} int i=1; int i=1; i 1 i <= n i n i++ i++ i {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		} {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		} dato = reader.nextInt() dato reader.nextInt() reader.nextInt reader if(dato != i) {
				++error;
			} dato != i dato i {
				++error;
			} ++error error if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO"); error <=2 error 2 System.out.println("YES") System.out.println System.out System System.out "YES" System.out.println("NO") System.out.println System.out System System.out "NO" String[] args args public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

} public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, dato, error=0;
		n = reader.nextInt();
		for(int i=1; i <= n; i++) {
			dato = reader.nextInt();
			if(dato != i) {
				++error;
			}
		}
		if(error <=2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}
