#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const unsigned long long LINF = INF * (unsigned long long)INF;
const double EPS = 1e-7;
const int MAX = 20 * 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;
const unsigned long long MAS = 1000 * 100 * 4 + 47;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int a[MAS];
int b[MAS];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  int sum = 0;
  for (int i = (0); i < (n); i++) {
    if (a[i] != b[i]) {
      sum++;
    }
  }
  if ((sum + 1) / 2 > 1) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
