#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005], n;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], b[i] = a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n && ans < 3; ++i) {
    ans += a[i] != b[i];
  }
  if (ans < 3)
    puts("YES");
  else
    puts("NO");
}
