#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  double x, y, z;
  cin >> x;
  vector<int> vec, v;
  for (int i = 0; i < x; i++) {
    cin >> y;
    vec.push_back(y);
    v.push_back(y);
  }
  long long L = 0, R = 0, n = 0;
  sort(vec.begin(), vec.end());
  for (int i = 0; i < x; i++) {
    if (vec[i] != v[i]) {
      n++;
    }
  }
  if (n > 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}
