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