#include <bits/stdc++.h>
using namespace std;
int arr[100010 + 1], arr1[100010 + 1];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr1[i] = arr[i];
  }
  sort(arr1, arr1 + n);
  for (int i = 0; i < n; i++)
    if (arr[i] != arr1[i]) x++;
  if (x == 0 || x == 2)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
