#include <bits/stdc++.h>
using namespace std;
bool isFile = 0;
const long long INF = 1e9 + 1234;
const int N = 2e5 + 5;
const long long MOD = 998244353;
const long long mod = 1e9 + 7;
double EPS = 3e18;
void faster() {
  if (isFile) {
    freopen(
        ""
        ".in",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int a[N];
int b[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) cnt += (a[i] != b[i]);
  if (cnt <= 2)
    cout << "Yes";
  else
    cout << "NO";
}
int main() {
  faster();
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
