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