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