import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	}
} Main public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	} main {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn int p[] = new int[N]; p new int[N] N int ans = 0; ans 0 for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		} {
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		} p[i] = stdIn.nextInt() p[i] p i stdIn.nextInt() stdIn.nextInt stdIn if(p[i]-i != 1){
				ans++;
			} p[i]-i != 1 p[i]-i p[i] p i i 1 {
				ans++;
			} ans++ ans if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		} ans == 2 || ans == 0 ans == 2 ans 2 ans == 0 ans 0 {
			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" stdIn.close() stdIn.close stdIn String[] args args public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int p[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			p[i] = stdIn.nextInt();
			if(p[i]-i != 1){
				ans++;
			}
		}
		if(ans == 2 || ans == 0){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
		stdIn.close();
	}
}