#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long N = 200005;
long long n;
void solve() {
  long long i, j, k;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  b = a;
  sort(a.begin(), a.end());
  long long cnt = 0;
  for (long long i = 0; i < n; i++)
    if (a[i] != b[i]) cnt++;
  if (cnt <= 2)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1, i, j, k;
  while (t--) {
    solve();
  }
  return 0;
}
