#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto& x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
long long mod(long long n);
long long gcd(long long a, long long b);
long long modM(long long n, long long m);
long long modA(long long n, long long m);
long long modS(long long n, long long m);
const long long int N = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < (long long)(n); ++i) cin >> arr[i];
  long long x = -1;
  long long y = -1;
  long long maxi = -1;
  long long max = INT_MIN;
  long long maxi2 = -1;
  long long max2 = INT_MIN;
  for (long long i = 0; i < (long long)(n); ++i) {
    if (max <= arr[i]) {
      max = arr[i];
      maxi = i;
    }
    if (max2 < arr[i]) {
      max2 = arr[i];
      maxi2 = i;
    }
    if (maxi != i) {
      x = i;
      y = maxi2;
    }
  }
  if (x == -1) {
    cout << "YES";
    return 0;
  }
  swap(arr[x], arr[y]);
  max = INT_MIN;
  for (long long i = 0; i < (long long)(n); ++i) {
    if (max <= arr[i]) {
      max = arr[i];
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long mod(long long n) { return (n % N + N) % N; }
long long modM(long long n, long long m) { return ((n % N * m % N) + N) % N; }
long long modA(long long n, long long m) { return ((n % N + m % N) + N) % N; }
long long modS(long long n, long long m) { return ((n % N - m % N) + N) % N; }
