#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, cnt = 0;
  cin >> n;
  long long a[n], b[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 <= 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
