#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, k = 0, n, t = 1, m, l = 0;
  while (t--) {
    cin >> n;
    long long a[n], b[n];
    for (i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(a, a + n);
    long long cnt = 0;
    for (i = 0; i < n; i++) {
      if (a[i] != b[i]) cnt++;
    }
    if (cnt <= 2) {
      cout << "YES"
           << "\n";
    } else
      cout << "NO"
           << "\n";
  }
  return 0;
}
