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