import java.util.Scanner;

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