#include <bits/stdc++.h>
using namespace std;
long long int a[100005], b[100005];
int main() {
  int n, i, c = 0;
  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]) c++;
    if (c > 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
