import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range, std.typecons, std.numeric, std.math;

void main() {
    long n = readln.strip.to!long;
    auto ps = readln.strip.split(" ").to!(long[]).array;

    long cnt = 0;
    foreach (i; 0..n) {
        if (ps[i] != i+1) {
            cnt++;
        }
    }

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