#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using pll = pair<ll, ll>;
using vll = vector<pll>;
using MAP = map<ll, ll>;
using sl = set<ll>;
using sll = set<pll>;
using MAPs = map<ll, sl>;
using MAPv = map<ll, vl>;
const ll inf = LLONG_MAX;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};
int n, a[N];
void MAIN() {
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) cin >> a[i], v.push_back(a[i]);
  sort((v).begin(), (v).end());
  int ind1 = 0, ind2 = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != v[i]) {
      cnt++;
      if (!ind1)
        ind1 = i;
      else
        ind2 = i;
    }
  }
  if (cnt > 2) {
    cout << "NO\n";
    return;
  }
  swap(a[ind1], a[ind2]);
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > a[i + 1]) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t-- > 0) {
    MAIN();
  }
}
