#include <bits/stdc++.h>
using namespace std;
int n, i;
int num;
int d[1000000], c[1000000];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c[i];
    d[i] = c[i];
  }
  sort(d, d + n);
  for (i = 0; i < n; i++)
    if (c[i] != d[i]) num++;
  if (num == 2 || num == 0) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}
