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