#include <bits/stdc++.h>
using namespace std;
void cas(int i) { cout << "Case " << i << ":"; }
bool sbs(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<long long> vv;
  vv.assign(v.begin(), v.end());
  sort(vv.begin(), vv.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] != vv[i]) cnt++;
  }
  if (cnt > 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
  ;
}
