#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, k, count = 0;
  vector<long long int> v, c;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> k;
    v.push_back(k);
  }
  c = v;
  sort(c.begin(), c.end());
  for (i = 0; i < v.size(); i++) {
    if (v[i] != c[i]) {
      count++;
      if (count > 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
