#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n;
int a[N];
pair<int, int> arrPos[N];
bool minSwaps() {
  for (int i = 0; i < n; i++) {
    arrPos[i].first = a[i];
    arrPos[i].second = i;
  }
  sort(arrPos, arrPos + n);
  vector<bool> vis(n, false);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i] || arrPos[i].second == i) continue;
    int cycle_size = 0;
    int j = i;
    while (!vis[j]) {
      vis[j] = 1;
      j = arrPos[j].second;
      cycle_size++;
    }
    ans += (cycle_size - 1);
    if (ans >= 2) return false;
  }
  return true;
}
int b[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  memcpy(b, a, sizeof a);
  sort(b, b + n);
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) ans++;
  if (ans <= 2) {
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}
