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