#a,b=map(int,input().split())

n=int(input())

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

import copy

P=copy.deepcopy(p)

P.sort()

cnt=0

for i,j in zip(p,P):

        if i!=j:

                cnt+=1

print("YES") if cnt<=2 else print("NO")

n=int(input())

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

#b=list(map(int,input().split()))

cnt=0

for i in range(n):

    if p[i]!=i+1:

        cnt+=1

print("YES") if cnt<=2 else print("NO")

# a,b=map(int,input().split())
n = int(input())
p = list(map(int, input().split()))
import copy

P = copy.deepcopy(p)
P.sort()
cnt = 0
for i, j in zip(p, P):
    if i != j:
        cnt += 1
print("YES") if cnt <= 2 else print("NO")

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

-# a,b=map(int,input().split()) -import copy - -P = copy.deepcopy(p) -P.sort() +# b=list(map(int,input().split())) -for i, j in zip(p, P): -    if i != j: +for i in range(n): +    if p[i] != i + 1: