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