#include <bits/stdc++.h>
using namespace std;
struct IOS {
  struct Input {
    int readInt() {
      int x;
      scanf("%d", &x);
      return x;
    }
    long long readLong() {
      long long x;
      scanf("%lld", &x);
      return x;
    }
    char readChar() {
      char c;
      scanf("%c", &c);
      return c;
    }
    double readDouble() {
      double x;
      scanf("%lf", &x);
      return x;
    }
    string readString() {
      char str[100005];
      scanf("%s", &str);
      return str;
    }
    void readIntArray(int* arr, int st, int en) {
      for (int i = st; i <= en; i++) arr[i] = readInt();
    }
  } in;
  struct Output {
    void newLine() { printf("\n"); }
  } out;
};
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    std::cout << v << ' ';
    return *this;
  }
} dbg;
int arr[100005], temp[100005];
int main(int argc, char const* argv[]) {
  IOS ios;
  int n = ios.in.readInt();
  ios.in.readIntArray(arr, 0, n - 1);
  for (int i = 0; i <= n - 1; i++) temp[i] = arr[i];
  sort(arr, arr + n);
  int res = 0;
  for (int i = 0; i <= n - 1; i++) res += (arr[i] != temp[i]);
  printf(res <= 2 ? "YES\n" : "NO\n");
  return 0;
}
