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