#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, a[100005], j, cnt = 0, b[100005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      cnt++;
      if (cnt > 2) {
        cout << "NO";
        return 0;
        break;
      }
    }
  }
  cout << "YES";
  return 0;
}
