#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0;
  cin >> n;
  int a[n];
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (a[i] != v[i]) count++;
  }
  if (count == 0 || count == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
