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