import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
} Main public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	} main {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] array = new int[a]; array new int[a] a int count = 0; count 0 for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        } {
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        } array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc if(!(array[i] == (i + 1))){
                count++;
            } !(array[i] == (i + 1)) (array[i] == (i + 1)) array[i] array i (i + 1) i 1 {
                count++;
            } count++ count if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        } count <= 2 count 2 {
            System.out.print("YES");
        } System.out.print("YES") System.out.print System.out System System.out "YES" {
            System.out.print("NO");
        } System.out.print("NO") System.out.print System.out System System.out "NO" String[] args args public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
} public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array = new int[a];
        int count = 0;

        for(int i = 0; i < a; i++){
            array[i] = sc.nextInt();
            if(!(array[i] == (i + 1))){
                count++;
            }
        }
        if(count <= 2){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
	}
}