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