#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-30;
const double INFD = 1e20;
const long long INFLL = 0x3f3f3f3f3f3f3f3fll;
const int INF = 0x3f3f3f3f;
const int maxn = (int)1e2 + 10;
const int MAXN = (int)1e5 + 10;
const int MOD = (int)1e9 + 7;
int main() {
  int a[100010];
  int b[100010];
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(a + 1, a + 1 + n);
    int cnt = 0;
    for (int i = 1; i <= n; i++)
      if (a[i] != b[i]) cnt++;
    if (cnt == 0 || cnt == 2 || cnt == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
