#include <bits/stdc++.h>
using namespace std;
long long n, cnt;
long long arr[100000], h[100000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i <= n - 1; i++) {
    cin >> arr[i];
    h[i] = arr[i];
  }
  sort(h, h + n);
  for (long long i = 0; i <= n - 1; i++) {
    if (arr[i] != h[i]) cnt++;
  }
  if (cnt > 2)
    cout << "NO\n";
  else
    cout << "YES\n";
  cin >> n;
  return 0;
}
