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