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