#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
const long long mod = 1e9 + 7;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long M = 300 + 10;
const long long N = 500 * 1000 + 10;
long long a[N], dp[N], b[N];
int main() {
  faster();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      ans++;
    }
  }
  if (ans < 3) {
    cout << "YES\n";
  } else
    cout << "NO\n";
}
