#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int ej=0;
    cin>>n;
    vector<int> value1,value2;
    for(int i=0;i<n;i++)
    {
        int m;
        cin>>m;
        value1.push_back(m);
    }
    value2=value1;
    sort(value1.begin(),value1.end());
    for(int i=0;i<n;i++)
    {
        if(value1[i]!=value2[i])
        {
            ej++;
        }
    }

    if(ej<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }


}