n=io.read("*n")
p={}

for i=1,n do
  table.insert(p, io.read("*n"))
end

c=0
j=0
for i=1,n do
  if p[i]~=j+1 then
    c=c+1
  end
  j=j+1
end

if c<=2 then
  print("YES")
else
  print(c)
  print("NO")
end