import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int x = 0; x 0 for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        } {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        } int num = scanner.nextInt(); num scanner.nextInt() scanner.nextInt scanner if (num - 1 != i) x++; num - 1 != i num - 1 num 1 i x++ x if (x <= 2) System.out.println("YES");
        else System.out.println("NO"); x <= 2 x 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 scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = 0;
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            if (num - 1 != i) x++;
        }

        if (x <= 2) System.out.println("YES");
        else System.out.println("NO");
    }
}
