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