n=int(eval(input()))

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

c=0

a=[]

b=[]

for i in range(n):

    if p[i]!=i+1:

        c+=1

        a.append(i+1)

        b.append(p[i])

if c==0:

    print("YES")

elif c==2:

    if a[0]==b[1]:

        print("YES")

    else:

        print("NO")

else:

    print("NO")

n=int(eval(input()))

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

c=0

a=[]

b=[]

for i in range(n):

    if p[i]!=i+1:

        c+=1

        a.append(i+1)

        b.append(p[i])

if c==0 or c==2:

    print("YES")

else:

    print("NO")

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

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

-if c == 0: +if c == 0 or c == 2: -elif c == 2: -    if a[0] == b[1]: -        print("YES") -    else: -        print("NO")