#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<string>
#include<string.h>
#include<stdio.h>

int main() {


    int n,i,j,c=0;
    cin >> n;
    int a[n];
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(i=1;i<=n;i++)
    {
       if(a[i] != i)
       {
           c++;
       }

    }
    if(c>2)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }




  return 0;

}





