#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int A[50];
int main()
{
    vector<int> vec;
    int n;
    cin>>n;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back(x);
        A[i]=x;
    }
    int Count=0;
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++){
        if(vec[i]!=A[i]){
            ++Count;
        }
    }
    if(Count==2) cout<<"YES"<<endl;
    else if (Count==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}
