import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                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) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
    
} Main public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    } main {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int a=sc.nextInt(); a sc.nextInt() sc.nextInt sc int count=0; count 0 for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        } int i=1; int i=1; i 1 i<=a i a i++ i++ i {
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        } {
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        } int b=sc.nextInt(); b sc.nextInt() sc.nextInt sc if(i!=b){
                count++;
            } i!=b i b {
                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) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
    
} public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                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) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int count=0;
        for(int i=1;i<=a;i++){
            int b=sc.nextInt();
            if(i!=b){
                count++;
            }
        }
        if(count>2){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
    
}
