#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return (int)a * (b / gcd(a, b)); }
int ara[100000 + 10], temp[100000 + 10];
int n;
bool ok() {
  for (int i = 0; i < n - 1; i++) {
    if (ara[i] > ara[i + 1]) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ara[i]);
    temp[i] = ara[i];
  }
  int left = 0, right = n - 1;
  if (ok()) {
    printf("YES\n");
    return 0;
  }
  sort(ara, ara + n);
  for (int i = 0; i < n; i++) {
    if (ara[i] != temp[i]) left++;
  }
  if (left > 2)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
