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