import java.util.Scanner;

public class Main {

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

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

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

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

public class Main {

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