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