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