#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int t[100005], t1[100005];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    t1[i] = t[i];
  }
  sort(t, t + n);
  int nb = 0;
  bool test = 1;
  for (int i = 0; i < n; i++) {
    if (t[i] != t1[i]) nb++;
    if (nb > 2) {
      test = 0;
      break;
    }
  }
  if (!test)
    cout << "NO" << '\n';
  else
    cout << "YES" << '\n';
}
