#include <bits/stdc++.h>
using namespace std;
int n, arr[(int)(2e5 + 10)], s, brr[(int)(2e5 + 10)];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i], brr[i] = arr[i];
  sort(arr + 1, arr + n + 1);
  for (int i = 1; i <= n; i++)
    if (arr[i] != brr[i]) s++;
  if (s == 0 or s == 2)
    puts("YES");
  else
    puts("NO");
}
