import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    } main {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    } {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        } Scanner input = new Scanner(System.in); input new Scanner(System.in) int mis = 0 mis 0 N; N N = input.nextInt() N input.nextInt() input.nextInt input for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            } int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            } {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            } int cur = input.nextInt(); cur input.nextInt() input.nextInt input if (cur != i+1)
                    mis++; cur != i+1 cur i+1 i 1 mis++ mis String ans = (mis <= 2) ? "YES" : "NO"; ans (mis <= 2) ? "YES" : "NO" (mis <= 2) mis 2 "YES" "NO" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
} public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        {
            Scanner input = new Scanner(System.in);
            int mis = 0, N;
            N = input.nextInt();

            for(int i = 0; i<N; i++) {
                int cur = input.nextInt();
                if (cur != i+1)
                    mis++;
            }
            String ans = (mis <= 2) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
}