#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int num[maxn];
int mp[maxn];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &num[i]);
      mp[i] = num[i];
    }
    sort(num, num + n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (mp[i] != num[i]) ans++;
    }
    if (ans > 2)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
