import java.util.Scanner;

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

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