#include <bits/stdc++.h>
using namespace std;
int i, j, k, m, n, l;
int a[1000000 + 10], b[1000000 + 10];
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < (n); ++i) scanf("%d", &a[i]);
    memcpy(b, a, sizeof(a));
    sort(b, b + n);
    k = 0;
    for (int i = 0; i < (n); ++i)
      if (a[i] != b[i]) k++;
    if (k <= 2)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
