#include <bits/stdc++.h>
const long long int mod = 998244353;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, n, cnt = 0;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) {
    if (a[i] != b[i]) cnt++;
  }
  if ((cnt + 1) / 2 <= 1)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
