#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100005], b[100005];
  int n, i, ans;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(a, a + n);
    for (i = 0, ans = 0; i < n; i++) {
      if (a[i] != b[i]) ans++;
    }
    if (ans <= 2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
