#include <bits/stdc++.h>
using namespace std;
int a[110000], b[110000];
int main() {
  int n;
  cin >> n;
  for (int k = 1; k <= n; k++) scanf("%d", &a[k]);
  for (int k = 1; k <= n; k++) b[k] = a[k];
  sort(a + 1, a + 1 + n);
  int ans = 0;
  for (int k = 1; k <= n; k++)
    if (a[k] != b[k]) ans++;
  if (ans <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
