n = int(eval(input()))

p = [int(x) for x in input().split()]



cnt =0



for i in range(n):

  if p[i] ==(i+1):

    continue

  else:

    cnt +=1

if cnt <= 2:

  print('YES')

else:

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

p = [int(_) for _ in input().split()]

cnt =0

for i in range(len(p)):

  if  p[i] !=(i+1):

    cnt +=1

print(('YES' if cnt <=2 else 'NO'))
n = int(eval(input()))
p = [int(x) for x in input().split()]
cnt = 0
for i in range(n):
    if p[i] == (i + 1):
        continue
    else:
        cnt += 1
if cnt <= 2:
    print("YES")
else:
    print("NO")

n = int(eval(input()))
p = [int(_) for _ in input().split()]
cnt = 0
for i in range(len(p)):
    if p[i] != (i + 1):
        cnt += 1
print(("YES" if cnt <= 2 else "NO"))

-p = [int(x) for x in input().split()] +p = [int(_) for _ in input().split()] -for i in range(n): -    if p[i] == (i + 1): -        continue -    else: +for i in range(len(p)): +    if p[i] != (i + 1): -if cnt <= 2: -    print("YES") -else: -    print("NO") +print(("YES" if cnt <= 2 else "NO"))