#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int ar[n], arr[n];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    arr[i] = ar[i];
  }
  sort(ar, ar + n);
  for (int i = 0; i < n; i++) {
    if (ar[i] != arr[i]) {
      cnt++;
    }
  }
  if (cnt <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
