#include <bits/stdc++.h>
using namespace std;
void slv() {
  long long n, a;
  cin >> n;
  vector<long long> v1, v2;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    v1.push_back(a);
    v2.push_back(a);
  }
  sort(v1.begin(), v1.end());
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (v1[i] != v2[i]) {
      cnt++;
    }
  }
  if (cnt > 2)
    puts("NO");
  else
    puts("YES");
}
int main(int argc, char *argv[]) {
  long long t;
  t = 1;
  while (t--) {
    slv();
  }
  return 0;
}
