import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto N = readln.split[0].to!int;
  auto p = readln.split.to!(int[]);

  auto ctr = 0;
  foreach(i, pi; p) {
    if(pi != i+1) ctr++;
  }
  if(ctr == 0 || ctr == 2) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}
