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