import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
} import java.util.*; util.* java import java.util.Collections; Collections java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] p = new int[N]; p new int[N] N for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            p[i] = Integer.parseInt(sc.next());
        } {
            p[i] = Integer.parseInt(sc.next());
        } p[i] = Integer.parseInt(sc.next()) p[i] p i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int sw = 0; sw 0 int w = 0; w 0 for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        } int i = 0; int i = 0; i 0 i < N-1 i N-1 N 1 i++ i++ i {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        } {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        } int min = p[i]; min p[i] p i int minidx = i; minidx i for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            } int j = i + 1; int j = i + 1; j i + 1 i 1 j < N j N j++ j++ j {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            } {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            } if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                } min > p[j] min p[j] p j {
                    min = p[j];
                    minidx = j;
                } min = p[j] min p[j] p j minidx = j minidx j if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            } minidx != i minidx i {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            } w = p[i] w p[i] p i p[i] = min p[i] p i min p[minidx] = w p[minidx] p minidx w sw++ sw if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        } sw <= 1 sw 1 {
            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 sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
} Main
import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        
        int sw = 0;
        int w = 0;
        for(int i = 0; i < N-1; i++) {
            int min = p[i];
            int minidx = i;
            for(int j = i + 1; j < N; j++) {
                if(min > p[j]) {
                    min = p[j];
                    minidx = j;
                }
            }
            if(minidx != i) {
                w = p[i];
                p[i] = min;
                p[minidx] = w;
                sw++;
            }
        }
        
        if(sw <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
}