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