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