#include <bits/stdc++.h>
using namespace std;
int a[1000 * 110], b[1000 * 110];
int main() {
  int n, x = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) x++;
  }
  if (x <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
