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