#include <bits/stdc++.h>
const long long MOD = 1000000007;
int main() {
  long long n;
  std::cin >> n;
  std::vector<long long> a(n, 0);
  for (long long i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  std::vector<long long> b = a;
  std::sort(b.begin(), b.end());
  long long count = 0;
  bool ans = true;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      ++count;
    }
    if (count > 2) {
      ans = false;
    }
  }
  if (ans) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}
