#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cont = 0;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      cont++;
    }
  }
  if (cont > 2) {
    cout << "NO";
  } else {
    cout << "YES";
  }
  return 0;
}
