n = int(eval(input()))

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

c = 0

for i in range(n):

    if p[i]!=i+1:

        c+=1

if c>2:

    print("NO")

else:

    print("YES")
x = int(eval(input()))

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

k = sorted(p)

count = 0

for i in range(0,x):

    if p[i] == k[i]:

        count += 1



if (x - count) == 2 or (x - count) == 0:

    print('YES')

else:

    print('NO')

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

x = int(eval(input()))
p = list(map(int, input().strip().split()))
k = sorted(p)
count = 0
for i in range(0, x):
    if p[i] == k[i]:
        count += 1
if (x - count) == 2 or (x - count) == 0:
    print("YES")
else:
    print("NO")

-n = int(eval(input())) -p = list(map(int, input().split())) -c = 0 -for i in range(n): -    if p[i] != i + 1: -        c += 1 -if c > 2: +x = int(eval(input())) +p = list(map(int, input().strip().split())) +k = sorted(p) +count = 0 +for i in range(0, x): +    if p[i] == k[i]: +        count += 1 +if (x - count) == 2 or (x - count) == 0: +    print("YES") +else: -else: -    print("YES")