#include <bits/stdc++.h>
using namespace std;
int n, i, y, p[1000000], c[1000000];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> c[i];
    p[i] = c[i];
  }
  sort(p, p + n);
  for (i = 0; i < n; i++)
    if (p[i] != c[i]) y += 1;
  if (y == 2 || y == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
