#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  vector<int> V1, V2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    V1.push_back(a);
    V2.push_back(a);
  }
  sort(V1.begin(), V1.end());
  int bad = 0;
  for (int i = 0; i < n; i++) {
    if (V1[i] != V2[i]) {
      bad++;
    }
  }
  if (bad <= 2) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  solve();
}
