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