#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> og(n);
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> og[i];
    v[i] = og[i];
  }
  sort(v.begin(), v.end());
  int diff = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] != og[i]) {
      diff++;
    }
  }
  if (diff <= 2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
