#include <bits/stdc++.h>
using namespace std;
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (auto(i) = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  long long cnt = 0;
  for (auto(i) = 0; i < n; i++) {
    if (a[i] != b[i]) cnt++;
  }
  cout << ((cnt > 2) ? "NO\n" : "YES\n");
  return 0;
}
