import std.stdio;
import std.conv;
import std.array;

void main()
{
    int N = readln.split[0].to!int;
    auto reader = readln.split;
    int[] a = new int[N];
    for(uint i = 0; i < N; i++){
        a[i] = reader[i].to!int;
    }

    int cnt = 0;
    for(uint i = 0; i < N; i++){
        if (a[i] != i + 1) cnt++;
    }

    if (cnt == 0 || cnt == 2){
        writeln("YES");
    } else {
        writeln("NO");
    }
}

