#include <bits/stdc++.h>
using namespace std;
int n, err;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%d", &n);
  int arr1[n], arr2[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr1[i]);
    arr2[i] = arr1[i];
  }
  sort(arr1, arr1 + n);
  for (int i = 0; i < n; i++) err += !!(arr1[i] - arr2[i]);
  cout << (err > 2 ? "NO" : "YES");
  return 0;
}
