#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < (int)(n); i++) cin >> v[i];
  vector<int> w((v).begin(), (v).end());
  sort((w).begin(), (w).end());
  vector<int> diff;
  for (int i = 0; i < (int)(n); i++) {
    if (v[i] != w[i]) diff.push_back(i);
  }
  if (diff.size() > 2) {
    cout << "NO" << endl;
    return;
  }
  if (diff.size() == 0) {
    cout << "YES" << endl;
    return;
  }
  swap(v[diff[0]], v[diff[1]]);
  bool ok = true;
  for (int i = 0; i < (int)(n - 1); i++) ok = ok && v[i] <= v[i + 1];
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  solve();
  return 0;
}
