import copy



n = int(eval(input()))

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

q = copy.copy(p)

q.sort()

c = 0



for i in range(n):

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

        c = c + 1



if c == 2 or c == 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 = c + 1



if c == 2 or c == 0:

    print("YES")

else:

    print("NO")
import copy

n = int(eval(input()))
p = list(map(int, input().split()))
q = copy.copy(p)
q.sort()
c = 0
for i in range(n):
    if p[i] != q[i]:
        c = c + 1
if c == 2 or c == 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 = c + 1
if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

-import copy - -q = copy.copy(p) -q.sort() -    if p[i] != q[i]: +    if p[i] != i + 1: