import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	}
} import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	}
} Main public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	} main {
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter ou = new PrintWriter(System.out); ou new PrintWriter(System.out) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int yono = 0; yono 0 for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		} {
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		} if(i + 1 != Integer.parseInt(sc.next())) yono++; i + 1 != Integer.parseInt(sc.next()) i + 1 i 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc yono++ yono if(yono <= 2) ou.println("YES");
		else ou.println("NO"); yono <= 2 yono 2 ou.println("YES") ou.println ou "YES" ou.println("NO") ou.println ou "NO" ou.flush() ou.flush ou String[]args args public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	}
} public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	}
} Main
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i + 1 != Integer.parseInt(sc.next())) yono++;
		}
		if(yono <= 2) ou.println("YES");
		else ou.println("NO");
		ou.flush();
	}
}