import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int count = 0; count 0 for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        } {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        } int s = scan.nextInt(); s scan.nextInt() scan.nextInt scan if(i != s){
                count+=1;
            } i != s i s {
                count+=1;
            } count+=1 count 1 System.out.println(count>2?"NO":"YES") System.out.println System.out System System.out count>2?"NO":"YES" count>2 count 2 "NO" "YES" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int s = scan.nextInt();
            if(i != s){
                count+=1;
            }
        }

        System.out.println(count>2?"NO":"YES");
    }
}
