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