#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> b;
  b = a;
  sort(b.begin(), b.end());
  vector<int> r;
  for (int i = 0; i < n; ++i)
    if (a[i] != b[i]) r.push_back(i);
  if (r.size() == 0) {
    cout << "YES";
    return 0;
  }
  if (r.size() >= 3) {
    cout << "NO";
    return 0;
  }
  if (a[r[0]] == b[r[1]] && a[r[1]] == b[r[0]])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
