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