#include <bits/stdc++.h>
long long mod = 1e9 + 7;
inline long long pwr(long long base, long long n, long long int b) {
  long long ans = 1;
  while (n > 0) {
    if (n % 2 == 1) ans = (ans * base) % b;
    base = (base * base) % b;
    n /= 2;
  }
  return ans % b;
}
struct range {
  long long int l, h;
};
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  int ct = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) ct++;
  }
  if (ct <= 2) {
    cout << "YES\n";
  } else
    cout << "NO\n";
  return 0;
}
