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