n = int(eval(input()))

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

ans = [i for i in range(1,n+1)]

cnt = 0

 

for i in range(n):

  if p[i] != ans[i]:

    cnt += 1

  if cnt > 2:

    print('NO')

    exit()

    

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

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

error = 0

for i in range(n):

    if p[i] != i+1:

        error += 1

    if error > 2:

        print('NO')

        exit()

print('YES')

n = int(eval(input()))
p = list(map(int, input().split()))
ans = [i for i in range(1, n + 1)]
cnt = 0
for i in range(n):
    if p[i] != ans[i]:
        cnt += 1
    if cnt > 2:
        print("NO")
        exit()
print("YES")

n = int(eval(input()))
p = list(map(int, input().split()))
error = 0
for i in range(n):
    if p[i] != i + 1:
        error += 1
    if error > 2:
        print("NO")
        exit()
print("YES")

-ans = [i for i in range(1, n + 1)] -cnt = 0 +error = 0 -    if p[i] != ans[i]: -        cnt += 1 -    if cnt > 2: +    if p[i] != i + 1: +        error += 1 +    if error > 2: