#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
const ld EPS = 1e-9;
inline int cmp(ld first, ld second = 0, ld tol = EPS) {
  return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;
}
const int MOD = 1;
inline int mod(ll first, int m = MOD) { return (int)(((first % m) + m) % m); }
const int N = 1e5 + 10;
int a[N], b[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) {
      for (int j = n - 1; j >= 0; j--)
        if (b[j] == a[i]) {
          swap(b[j], b[i]);
          break;
        }
      break;
    }
  for (int i = 0; i < n - 1; i++)
    if (b[i] > b[i + 1]) {
      printf("NO\n");
      return 0;
    }
  printf("YES\n");
  return 0;
}
