#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, a[MAXN], b[MAXN], res;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) res++;
  if (res <= 2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
