#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> v(n), v1(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    v1[i] = v[i];
  }
  std::sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) n += v[i] != v1[i];
  return puts(n - v.size() < 3 ? "YES" : "NO"), 0;
}
