#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a;
  vector<int> b;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a.push_back(x);
    b.push_back(x);
  }
  sort(b.begin(), b.end());
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != a[i]) {
      count++;
      if (count > 2) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
  return 0;
}
