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