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