#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(false);
  int n, arra[100010], arrb[100010];
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    cin >> arra[i];
    arrb[i] = arra[i];
  }
  sort(arrb, arrb + n);
  int cnt = 0;
  for (int i = 0; i < (int)(n); i++)
    if (arra[i] != arrb[i]) cnt++;
  if (cnt == 2 || cnt == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
