import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      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 a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      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 a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      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 a; a int count = 0; count 0 for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      } {
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      } a = sc.nextInt() a sc.nextInt() sc.nextInt sc if(a==i+1){
        count += 1;
        } a==i+1 a i+1 i 1 {
        count += 1;
        } count += 1 count 1 if(n - count>=3){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    } n - count>=3 n - count n count 3 {
      System.out.println("NO");
    } System.out.println("NO") System.out.println System.out System System.out "NO" {
      System.out.println("YES");
    } 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 a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      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 a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      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 a;
    int count = 0;

    for(int i=0; i<n; i++){
      a = sc.nextInt();
      if(a==i+1){
        count += 1;
        }
      }
    if(n - count>=3){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }
  }
}
