#include <bits/stdc++.h>
using namespace std;
long long GCDFast(long long a, long long b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
int dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long a[100005], b[100005];
int main() {
  long long n, i, j, k, temp, m;
  long long x, y, z, sum, test_case = 0, length, ans, test = 0, l, w, num;
  string str, str1;
  i = 1;
  long long d;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> a[i];
      b[i] = a[i];
    }
    bool flag = true;
    int count = 0;
    sort(b, b + n);
    for (i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        count++;
      }
    }
    if (count <= 2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
