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