#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool isprime(long long n) {
  for (long long i = 2; (long long)i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long fib(int n) {
  long long a = 0, b = 1, c, i;
  if (n == 0) return a;
  for (i = 2; i <= n; i++) {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long extendedgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long d = extendedgcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
long long findgrouplcm(vector<int> &arr, int n) {
  long long ans = arr[0];
  for (long long i = 1; i < n; i++) ans = (arr[i] * (ans / (gcd(arr[i], ans))));
  return ans;
}
long long powerwithmod(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first < b.first;
  if (a.first == b.first) return a.second < b.second;
}
bool check(long arr[], int n) {
  for (long long i = (1); i < (n); i += (1)) {
    if (arr[i] < arr[i - 1]) return false;
  }
  return true;
}
void solve() {
  long n;
  cin >> (n);
  long arr[n];
  bool ok = true;
  for (long long i = 0; i < n; i++) cin >> (arr[i]);
  if (check(arr, n)) {
    cout << ("YES");
    return;
  }
  for (int i = n - 1; i >= 0; i--) {
    int pos = -1;
    for (int j = i - 1; j >= 0; j--) {
      if (arr[j] > arr[i]) pos = j;
    }
    if (pos != -1) {
      swap(arr[i], arr[pos]);
      if (check(arr, n)) {
        cout << ("YES");
        return;
      } else {
        cout << ("NO");
        return;
      }
    }
  }
}
int main() {
  fast();
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
