#include <bits/stdc++.h>
using namespace std;
int a1[500001];
int a[500001];
int main() {
  int n, t, i, j, n1, k, m, f = 0, s = 0, c = 0, p = 1, c1 = 0, p1 = 0, p2 = 0,
                            res = 0, c2, s1, s2, ss, pp, q;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    a1[i] = a[i];
  }
  sort(a, a + n);
  c = 0;
  for (i = 0; i < n; i++) {
    if (a[i] != a1[i]) {
      c++;
    }
  }
  if (c > 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}
