#include <bits/stdc++.h>
using namespace std;
int n, t, k, a, b, x, y, i, j, m[100005], p[100005];
int main() {
  cin >> n;
  while (i < n) {
    cin >> m[i];
    p[i] = m[i];
    i++;
  }
  i = 0;
  sort(p, p + n);
  while (i < n) {
    if (m[i] != p[i]) {
      x++;
    }
    i++;
  }
  i = 0;
  if (x == 0 || x == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
