#include <bits/stdc++.h>
using namespace std;
int a[100000 + 2], sa[100000 + 2];
vector<int> pos;
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      sa[i] = a[i];
    }
    sort(sa, sa + n);
    int cnt = 0, pos1 = -1, pos2 = -1;
    bool can = true;
    for (int i = 0; i < n; i++) {
      if (a[i] != sa[i]) pos.push_back(i);
    }
    if (pos.size() == 0)
      printf("YES\n");
    else if (pos.size() == 1)
      printf("NO\n");
    else {
      swap(a[pos[0]], a[pos[1]]);
      for (int i = 1; i < n and can; i++) {
        if (a[i] < a[i - 1]) can = false;
      }
      printf("%s\n", can ? "YES" : "NO");
    }
    pos.clear();
  }
}
