import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    } main {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int ans=0; ans 0 boolean flg=true; flg true for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        } int i=0; int i=0; i 0 i<a i a i++ i++ i {
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        } {
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        } int c=scan.nextInt(); c scan.nextInt() scan.nextInt scan if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            } i+1!=c i+1 i 1 c {
                ans+=1;
                if(ans==3){flg=false;break;}
            } ans+=1 ans 1 if(ans==3){flg=false;break;} ans==3 ans 3 {flg=false;break;} flg=false flg false break; String b = flg?"YES":"NO"; b flg?"YES":"NO" flg "YES" "NO" System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int ans=0;
        boolean flg=true;
        for(int i=0;i<a;i++){
            int c=scan.nextInt();
            if(i+1!=c){
                ans+=1;
                if(ans==3){flg=false;break;}
            }
        }
        String b = flg?"YES":"NO";
        System.out.println(b);
    }
}