#include <bits/stdc++.h>
using namespace std;
long long arr[1000005], brr[1000005];
int main() {
  long long n, x, y, cnt = 0;
  bool flag1 = false, flag2 = false;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
    brr[i] = arr[i];
  }
  sort(brr + 1, brr + n + 1);
  for (int i = 1; i <= n; i++) {
    if (arr[i] != brr[i]) cnt++;
  }
  if (cnt == 2 || cnt == 0) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
}
