import java.util.Scanner;

public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    }
} Main public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    } main {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int N = s.nextInt(); N s.nextInt() s.nextInt s int i=1; i 1 String result = "YES"; result "YES" int count = 0; count 0 while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        } i<=N i N {
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        } int p = s.nextInt(); p s.nextInt() s.nextInt s count += i!=p?1:0 count i!=p?1:0 i!=p i p 1 0 if(count>2){
                result = "NO";
                break;
            } count>2 count 2 {
                result = "NO";
                break;
            } result = "NO" result "NO" break; i++ i System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    }
} public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String args[] ) throws Exception {


        Scanner s = new Scanner(System.in);


        int N = s.nextInt();    // Reading input from STDIN

        int i=1;

        String result = "YES";
        int count = 0;
        while(i<=N){
            int p = s.nextInt();
            count += i!=p?1:0;

            if(count>2){
                result = "NO";
                break;
            }
            i++;
        }
        System.out.println(result);

    }
}
