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