#include <bits/stdc++.h>
const int INF = (int)(1e9);
const long long INFLL = (long long)(1e18);
const double EPS = 1e-13;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> nums(n), sorted(n);
  int diff = 0;
  for (int i = (0); i < (int)(n); i++) {
    cin >> nums[i];
    sorted[i] = nums[i];
  }
  sort((sorted).begin(), (sorted).end());
  for (int i = (0); i < (int)(n); i++) {
    if (sorted[i] != nums[i]) diff++;
  }
  if (diff == 0 || diff == 2)
    cout << "YES\n";
  else
    cout << "NO\n";
}
