import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    }

} Main public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    } main {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    } InputStreamReader is = new InputStreamReader(System.in); is new InputStreamReader(System.in) BufferedReader reader = new BufferedReader(is); reader new BufferedReader(is) List<String> mylist = new ArrayList<>(); mylist new ArrayList<>() String strinput = reader.readLine(); strinput reader.readLine() reader.readLine reader while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        } strinput != null strinput null {

            mylist.add(strinput);
            strinput = reader.readLine();

        } mylist.add(strinput) mylist.add mylist strinput strinput = reader.readLine() strinput reader.readLine() reader.readLine reader String arr01[] = mylist.get(0).split(" "); arr01 mylist.get(0).split(" ") mylist.get(0).split mylist.get(0) mylist.get mylist 0 " " String arr02[] = mylist.get(1).split(" "); arr02 mylist.get(1).split(" ") mylist.get(1).split mylist.get(1) mylist.get mylist 1 " " String n = arr01[0]; n arr01[0] arr01 0 int cnt = 0; cnt 0 Boolean chkflg = true; chkflg true for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        } int i = 1; int i = 1; i 1 i <= Integer.valueOf(n) i Integer.valueOf(n) Integer.valueOf Integer n i++ i++ i {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        } {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        } if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            } Integer.valueOf(arr02[i - 1]) != i Integer.valueOf(arr02[i - 1]) Integer.valueOf Integer arr02[i - 1] arr02 i - 1 i 1 i {
                cnt += 1;
            } cnt += 1 cnt 1 if (cnt > 2) {
                chkflg = false;
                break;
            } cnt > 2 cnt 2 {
                chkflg = false;
                break;
            } chkflg = false chkflg false break; System.out.println(chkflg ? "YES" : "NO") System.out.println System.out System System.out chkflg ? "YES" : "NO" chkflg "YES" "NO" String[] args args public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    }

} public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String n = arr01[0];

        int cnt = 0;
        Boolean chkflg = true;

        for (int i = 1; i <= Integer.valueOf(n); i++) {
            if (Integer.valueOf(arr02[i - 1]) != i) {
                cnt += 1;
            }
            if (cnt > 2) {
                chkflg = false;
                break;
            }
        }

        System.out.println(chkflg ? "YES" : "NO");
    }

}