#include <bits/stdc++.h>
using namespace std;
long long arr[100000 + 10], sorted[100000 + 10];
void scanArr(long long n) {
  for (int i = 0; i < n; i++) cin >> arr[i];
}
void scan(long long &n) { cin >> n; }
void printArr(long long a[], long long size) {
  for (int i = 0; i < size; i++) {
    if (i == 0)
      cout << a[i];
    else
      cout << " " << a[i];
  }
  cout << endl;
}
void print(long long &n) {
  if (&n == &arr[0])
    cout << n;
  else
    cout << " " << n;
}
int main() {
  long long n;
  while (cin >> n) {
    scanArr(n);
    copy(arr, arr + n, sorted);
    sort(sorted, sorted + n);
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] != sorted[i]) cnt++;
    }
    if (cnt < 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
