import std.stdio, std.string, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] p = readln.split.to!(int[]);
    int cnt;
    foreach (i, x; p) {
        if (x != i + 1) ++cnt;
    }
    writeln(cnt < 3 ? "YES" : "NO");
}