#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n), temp;
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  temp = arr;
  sort(temp.begin(), temp.end());
  bool flag = true;
  long long int chnges = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != temp[i]) chnges++;
    if (chnges > 2) {
      flag = false;
      break;
    }
  }
  if (flag)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  solve();
  return 0;
}
