#include <bits/stdc++.h>
using namespace std;
int N;
int A[100001];
pair<int, int> B[100001];
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second < b.second;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    B[i].first = A[i];
    B[i].second = i;
  }
  sort(B + 1, B + N + 1, comp);
  int cnt = 0;
  for (int i = 1; i <= N; i++)
    if (A[i] != B[i].first) cnt++;
  if (cnt == 0 || cnt == 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
