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