#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int t[100000];
  int r[100000];
  int n, w = 0, p = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t[i];
    r[i] = t[i];
  }
  sort(t, t + n);
  for (i = 0; i < n; i++) {
    if (t[i] != r[i]) {
      w++;
    }
  }
  if (w <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
