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