#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort((a).begin(), (a).end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      cnt++;
    }
  }
  if (cnt < 3) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  T = 1;
  while (T--) {
    solve();
  }
}
