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