import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} Main public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } main {

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int a = s.nextInt(); a s.nextInt() s.nextInt s int b[] = new int[a]; b new int[a] a int count = 0; count 0 for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        } int i = 0; int i = 0; i 0 i < a i a i++ i++ i {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        } {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        } b[i] = s.nextInt() b[i] b i s.nextInt() s.nextInt s if (b[i] != (i+1)) {
                count++;
            } b[i] != (i+1) b[i] b i (i+1) i 1 {
                count++;
            } count++ count if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        } count <= 2 count 2 {
            System.out.println("YES");
        } System.out.println("YES") System.out.println System.out System System.out "YES" {
            System.out.println("NO");
        } System.out.println("NO") System.out.println System.out System System.out "NO" String[] args args public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
} Main
import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b[] = new int[a];

        int count = 0;

        for (int i = 0; i < a; i++) {
            b[i] = s.nextInt();
            
            if (b[i] != (i+1)) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}