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