#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) scanf("%d", &a[i]);
  vector<int> b = a;
  sort((b).begin(), (b).end());
  int cnt = 0;
  for (int i = 0; i < int(n); i++)
    if (b[i] != a[i]) cnt++;
  if (cnt <= 2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
