#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, cnt = 0;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ind[n];
  ind[0] = 0;
  for (long long i = 1; i <= n - 1; i++) {
    ind[i] = i;
    if (a[ind[i - 1]] >= a[ind[i]]) ind[i] = ind[i - 1];
  }
  for (i = n - 1; i >= 0; i--) {
    if (ind[i] < i && a[ind[i]] != a[i]) {
      swap(a[ind[i]], a[i]);
      break;
    }
  }
  for (long long i = 1; i <= n - 1; i++) {
    if (a[i] < a[i - 1]) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  cout << "YES"
       << "\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;
}
