N = int(eval(input()))

lis_p = list(map(int, input().split()))



lis_ans = sorted(lis_p)



count = 0

for i in range(N):

    if lis_p[i] != lis_ans[i]:

        count += 1



if count == 2 or count == 0:

    print("YES")

else:

    print("NO")
n=int(eval(input()))

p=list(map(int,input().split()))

g=sum((1 for i in range(n) if i+1 !=p[i]))

print(("YNEOS"[::2] if g==2 or g==0 else "YNEOS"[1::2]))
N = int(eval(input()))
lis_p = list(map(int, input().split()))
lis_ans = sorted(lis_p)
count = 0
for i in range(N):
    if lis_p[i] != lis_ans[i]:
        count += 1
if count == 2 or count == 0:
    print("YES")
else:
    print("NO")

n = int(eval(input()))
p = list(map(int, input().split()))
g = sum((1 for i in range(n) if i + 1 != p[i]))
print(("YNEOS"[::2] if g == 2 or g == 0 else "YNEOS"[1::2]))

-N = int(eval(input())) -lis_p = list(map(int, input().split())) -lis_ans = sorted(lis_p) -count = 0 -for i in range(N): -    if lis_p[i] != lis_ans[i]: -        count += 1 -if count == 2 or count == 0: -    print("YES") -else: -    print("NO") +n = int(eval(input())) +p = list(map(int, input().split())) +g = sum((1 for i in range(n) if i + 1 != p[i])) +print(("YNEOS"[::2] if g == 2 or g == 0 else "YNEOS"[1::2]))