/*

AUTHOR : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


  ___  _   _    __    _  _  ____    __    _  _
 / __)( )_( )  /__\  ( \( )(  _ \  /__\  ( \( )
( (__  ) _ (  /(__)\  )  (  )(_) )/(__)\  )  (
 \___)(_) (_)(__)(__)(_)\_)(____/(__)(__)(_)\_)




*/
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<cstdio>
#define MAX 10000001
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<unordered_map>
#define ll long long
#define ld long double
#define lli long long int
#define pb push_back
#define INF 1000000000
#define mod 1000000007
#define MOD 1000000007
//#define mp make_pair
#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<lli,lli>
#define vi vector<lli>
#define vvi vector<lli>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define abs(x) ((x < 0)?-(x):x)
#define print(x) printf("%lli\n",x);
#define print2(x,y) printf("%lli %lli\n",x,y);
#define print3(x,y,z) printf("%lli %lli %lli\n",x,y,z);
#define scan(x) scanf("%lli",&x);
#define scan2(x,y) scanf("%lli %lli",&x,&y);
#define scan3(x,y,z) scanf("%lli %lli %lli",&x,&y,&z);
#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" ";    cout<<"\n";
#define scanarr(a,n) for(lli i=0;i<n;i++)    scan(a[i]);
// cout<<fixed<<setprecision(6)<<value;
using namespace std;

lli find_mod(string s){
lli i,x=0;
for(i=0;i<s.length();i++)
    x=(x*10+s[i]-'0')%MOD;
return x;
}
long XOR(lli n)
{

    switch(n & 3) // n % 4
    {
    case 0: return n;     // if n is multiple of 4
    case 1: return 1;
    case 2: return n + 1;
    case 3: return 0;
    }
}

lli prime[MAX+1];

void sieve1(){ //prime or not
    for(int i=0;i<=MAX;i++) prime[i]=1;
    prime[0]=prime[1]=0;
    for (int p=2; p*p<=MAX; p++){
        if (prime[p] == 1)
            for (int i=p*p; i<=MAX; i += p){
                prime[i] = 0;


}}}

int min_prime_div_of_n[MAX+1];

void sieve2(){ //smallest prime factor which divide a no.
memset(min_prime_div_of_n, 0, sizeof(min_prime_div_of_n));
	min_prime_div_of_n[0] = min_prime_div_of_n[1] = 1;
	for (int i = 2; i * i <= MAX; i++) {
		if (min_prime_div_of_n[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (min_prime_div_of_n[j] == 0){
					min_prime_div_of_n[j] = i;
					//cout<<min_prime_div_of_n[i]<<" ";}
			}
		}
	}
}
	for (int i = 2; i <=MAX; i++)
		if (min_prime_div_of_n[i] == 0)
			min_prime_div_of_n[i] = i;
		// If the number is prime then it's // smallest prime factor is the number // itself
}

int max_prime_div_of_n[MAX+1];

void sieve3(){ //maximum prime factor which divide a no.
    sieve1();
    memset(max_prime_div_of_n, 0, sizeof(max_prime_div_of_n));   //0 stands for is prme or not
	max_prime_div_of_n[0] = max_prime_div_of_n[1] = 1;
	for (int i = 2; i * i <= MAX; i++) {
		if (max_prime_div_of_n[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (max_prime_div_of_n[j] == 0 || ((j%i)==0 && prime[i]==1) ){
					max_prime_div_of_n[j] = i;
                    }
			}
		}
	}
	for (int i = 2; i <=MAX; i++)
		if (max_prime_div_of_n[i] == 0)//{
			max_prime_div_of_n[i] = i;
			//cout<<max_prime_div_of_n[i]<<" ";}
		// If the number is prime then it's largest prime factor is the number  itself
}

bool is_even(lli n){ return(n%2==0);}

bool is_odd(lli n){ return(n%2==1);}

/*bool isPower(lli n)
{
	// Find Log n in different bases
	// and check if the value is an
	// integer
	float f=log(n)/log(2);
	if (((f - (int)f) == 0.0) && prime[int(f)]==1)
			return true;
	for (lli x=3; x<=sqrt(n); x+=2) {
		f = log(n) / log(x);
		if (((f - (int)f) == 0.0) && prime[int(f)]==1 && prime[x]==1 )
			return true;
	}
	return false;
}
*/
// memset(array_name , initialized value , sizeof(data_type_of_array))
lli sum(lli n){
    lli sum=0;
while(n){
    sum+=n%10;
    n/=10;
}
return sum;
}

bool isPrime(lli n){
if(n<=1) return false;
if(n<=3) return true;
if(n==5) return true;
if((n%2==0)||(n%3==0) || (n%5==0)) return false;
for(lli i=5;i*i<=n;i+=6)
    if((n%i==0)||(n%(i+2)==0))
        return false;
return true;
}

lli reversenum(lli x){
lli num=0;
while(x>0){
num=num*10+x%10;
x=x/10;
}
return num;
}

bool ispalindrome(string s){
string q = s;
reverse(q.begin(),q.end());
return(s==q);
}

bool isvowel(char x){
return(x=='a' || x== 'e' ||x=='i' || x== 'o' || x=='u' );
}

/*inline void fastRead(lli &x) {
	    register int c = getchar_unlocked();
	    x = 0;
	    int neg = 0;
	    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());
	    if(c=='-'){
	    	neg = 1;
	        c = getchar_unlocked();}
	    for(; c>47 && c<58 ; c = getchar_unlocked()){x = (x<<1) + (x<<3) + c - 48;}
	    if(neg){ x = -x;}
}*/



lli sumarr(lli a[],lli n){
    lli sum=0;
    loop(i,n) sum+=a[i];
    return sum;
}

ll mul(ll a, ll b) {
	return ((a%mod) * (b%mod)) % mod;
}

ll fastExpo(ll n, ll e) {
	if(e == 0) return 1LL;
	if(e == 1LL) return n%mod;
	if(e&1) return mul(n, fastExpo(n, e-1LL));
	ll aux = fastExpo(n, e/2LL);
	return mul(aux, aux);
}

lli findmax(lli a[],lli x,lli y){

lli maxi=-1;
for(lli i=x;i<=y;i++){
maxi = max(maxi , a[i]);
}
return maxi;
}

int main(){
lli n;
cin>>n;
lli a[n],b[n];
loop(i,n){
cin>>a[i];
b[i]=a[i];
}
sort(b,b+n);
lli cnt=0;
loop(i,n){
if(a[i]!=b[i]) cnt++;
}
if(cnt==0 || cnt==2) cout<<"YES";
else cout<<"NO";
return 0;
}


Measured memory_bytes: 256