
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
} import java.util.Scanner; Scanner java.util public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
} Main /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    } main {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        } int i = 1; int i = 1; i 1 i < n+1 i n+1 n 1 i++ i++ i {
            if(i != sc.nextInt())count++;
        } {
            if(i != sc.nextInt())count++;
        } if(i != sc.nextInt())count++; i != sc.nextInt() i sc.nextInt() sc.nextInt sc count++ count if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        } count<3 count 3 {
            System.out.print("YES");
        } System.out.print("YES") System.out.print System.out System System.out "YES" {
            System.out.print("NO");
        } System.out.print("NO") System.out.print System.out System System.out "NO" String[] args args public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
} public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
} Main

import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
}
