import java.util.*;

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

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