#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long n, b[100000], ans;
pair<long long, long long> a[100000];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> b[i];
  for (long long i = 0; i < n; i++) {
    a[i].first = b[i];
    a[i].second = i;
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++)
    if (a[i].first != b[i]) {
      ans++;
    }
  if (ans <= 2) {
    return cout << "YES", 0;
  } else {
    return cout << "NO", 0;
  }
  return 0;
}
