#include <bits/stdc++.h>
using namespace std;
int a[100001], b[100001];
int t;
int main() {
  int i, j, n, m;
  while (scanf("%d", &n) != EOF) {
    int flag = 0, cnt = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(a + 1, a + 1 + n);
    for (i = 1; i <= n; i++) {
      if (a[i] != b[i]) {
        cnt++;
      }
      if (cnt >= 3) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
