#include <bits/stdc++.h>
using namespace std;
template <class T>
static void print_stl_cont(const T& v, const string& desc = "") {
  if (!desc.empty()) {
    cerr << desc << ": ";
  }
  int i = 0;
  for (auto x : v) {
    cerr << "[" << i++ << "]=" << x.first << "," << x.second << " ";
  }
  cerr << endl;
}
bool issorted(const vector<int>& a, int i1, int i2) {
  if (i1 > 0 && a[i1 - 1] > a[i1]) return false;
  if (i2 > 0 && a[i2 - 1] > a[i2]) return false;
  if (i1 < a.size() - 1 && a[i1] > a[i1 + 1]) return false;
  if (i2 < a.size() - 1 && a[i2] > a[i2 + 1]) return false;
  for (int i = 1; i < (int)a.size(); ++i) {
    if (a[i - 1] > a[i]) return false;
  }
  return true;
}
int main() {
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  ;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  };
  vector<int> indices;
  for (int i = 1; i < n; ++i) {
    if (a[i - 1] <= a[i]) {
      continue;
    }
    indices.push_back(i - 1);
    indices.push_back(i);
    break;
  }
  if (indices.empty()) {
    cout << "YES\n";
    return 0;
  }
  bool ok = false;
  for (auto i1 : indices) {
    for (int i2 = 0; i2 < n; ++i2) {
      swap(a[i1], a[i2]);
      if (issorted(a, i1, i2)) {
        ok = true;
        break;
      }
      swap(a[i1], a[i2]);
    }
  }
  cout << (ok ? "YES" : "NO");
  return 0;
}
