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