#include <bits/stdc++.h>
using namespace std;
int n, i, x[100001], y[100001], m;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }
  sort(y + 1, y + n + 1);
  for (i = 1; i <= n; i++)
    if (x[i] != y[i]) m++;
  if (m == 0 || m == 2) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
