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