#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n], a2[n], c = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a2[i] = a[i];
  }
  sort(a2, a2 + n);
  for (int i = 0; i < n; ++i) {
    if (a2[i] != a[i]) c++;
  }
  if (c <= 2)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return (0);
}
