#include <bits/stdc++.h>
using namespace std;
int n, i, cnt;
vector<int> g, pr;
int main(int argc, const char* argv[]) {
  cin >> n;
  g.resize(n);
  pr.resize(n);
  for (i = 0; i < n; i++) {
    cin >> g[i];
    pr[i] = g[i];
  }
  sort(pr.begin(), pr.end());
  for (i = 0; i < n; i++) {
    if (g[i] != pr[i]) {
      cnt++;
    }
  }
  if (cnt > 2) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
