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