#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toll(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
int main() {
  int n, i, c = 0, f, s;
  cin >> n;
  vector<int> A(n), tmp(n);
  for ((i) = 0; (int)(i) < (n); (i)++) {
    cin >> A[i];
    tmp[i] = A[i];
  }
  sort(A.begin(), A.end());
  for ((i) = 0; (int)(i) < (n); (i)++) {
    if (A[i] != tmp[i]) {
      c++;
    }
  }
  if (c <= 2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
