#include <bits/stdc++.h>
using namespace std;
vector<int> m;
vector<int> sortm;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    m.push_back(a);
    sortm.push_back(a);
  }
  sort(sortm.begin(), sortm.end());
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (m[i] != sortm[i]) count++;
  }
  if (count == 0 || count == 2)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
