#include <bits/stdc++.h>
using namespace std;
int p[100010], m[100010];
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int n, c = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    m[i] = p[i];
  }
  qsort(p, n, sizeof(int), compare);
  for (int i = 0; i < n; ++i) {
    if (m[i] != p[i]) c++;
  }
  if (c == 2 || !c)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
