#include <bits/stdc++.h>
const double eps = 0.00001;
using namespace std;
int f[100005];
int t[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> f[i];
  }
  memcpy(t, f, sizeof(f));
  int sum = 0;
  sort(t + 1, t + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (f[i] != t[i]) sum++;
  }
  if (sum == 2 || sum == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
