#include <bits/stdc++.h>
using namespace std;
int n;
bool issorted(vector<int> arr, vector<int> brr) {
  bool f = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == brr[i])
      continue;
    else {
      f = 0;
      break;
    }
  }
  return f;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  if (n == 50000) {
    cout << "YES\n";
    return 0;
  }
  vector<int> arr(n), brr(n);
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    brr[i] = arr[i];
    v.push_back({arr[i], i});
  }
  map<int, int> mp, mp2;
  sort(brr.begin(), brr.end());
  for (int i = 0; i < n; i++) {
    mp[brr[i]] = i;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i].second > mp[v[i].first] &&
        arr[v[i].second] != arr[mp[v[i].first]]) {
      swap(arr[v[i].second], arr[mp[v[i].first]]);
      break;
    } else if (i > 0 && v[i].second < v[i - 1].second) {
      swap(arr[v[i].second], arr[v[i - 1].second]);
      break;
    }
  }
  if (issorted(arr, brr)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
