#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int m[maxn + 5], p[maxn + 5];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &m[i]);
    p[i] = m[i];
  }
  sort(p + 1, p + n + 1);
  int num = 0;
  for (int i = 1; i <= n; ++i)
    if (m[i] != p[i]) ++num;
  if (num == 0 || num == 2)
    puts("YES");
  else
    puts("NO");
  return 0;
}
