#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n], b[n], i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  int res = 0, cnt = 0;
  sort(b, b + n);
  for (i = 0; i < n; i++) {
    if (a[i] != b[i]) cnt++;
  }
  if (cnt == 2 || cnt == 0)
    cout << "Yes";
  else
    cout << "No";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
