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