import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

        if (counter <= 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

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

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

        if (counter <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

        if (counter <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int counter = 0; counter 0 for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        } {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        } int p = sc.nextInt(); p sc.nextInt() sc.nextInt sc if (p != i) {
                counter++;
            } p != i p i {
                counter++;
            } counter++ counter sc.close() sc.close sc if (counter <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        } counter <= 2 counter 2 {
            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" String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

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

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

        if (counter <= 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int counter = 0;
        for (int i = 1; i <= n; i++) {
            int p = sc.nextInt();
            if (p != i) {
                counter++;
            }
        }
        sc.close();

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

}
