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