import java.util.*;
 
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
} 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[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  } main {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] array = new int[n]; array new int[n] n for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
      array[i] = sc.nextInt();
    } {
      array[i] = sc.nextInt();
    } array[i] = sc.nextInt() array[i] array i sc.nextInt() sc.nextInt sc int count = 0; count 0 String result = "YES"; result "YES" for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    } int j = 1; int j = 1; j 1 j <= n j n j ++ j ++ j {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    } {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    } if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      } array[j - 1] != j array[j - 1] array j - 1 j 1 j {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      } count ++ count if (count == 3) {
          result = "NO";
          break;
        } count == 3 count 3 {
          result = "NO";
          break;
        } result = "NO" result "NO" break; System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
} public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
} Main
import java.util.*;
 
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 1; j <= n; j ++) {
      if (array[j - 1] != j) {
        count ++;
        if (count == 3) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
}