n = eval(input())

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



ps = sorted(p)



d_p = []

d_ps = []

for i,q in enumerate(p):

  if q != ps[i]:

    d_p.append(q)

    d_ps.append(ps[i])

if len(d_p) > 2:

  print('NO')

elif len(d_p) == 2:

  d_p.sort()

  if d_p == d_ps:

    print('YES')

  else:

    print('NO')

else:

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

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



ps = sorted(p)



count = 0

for q, qs in zip(p, ps):

  if q != qs:

    count += 1

    

print(('YES' if count <= 2 else 'NO'))
n = eval(input())
p = list(map(int, input().split()))
ps = sorted(p)
d_p = []
d_ps = []
for i, q in enumerate(p):
    if q != ps[i]:
        d_p.append(q)
        d_ps.append(ps[i])
if len(d_p) > 2:
    print("NO")
elif len(d_p) == 2:
    d_p.sort()
    if d_p == d_ps:
        print("YES")
    else:
        print("NO")
else:
    print("YES")

n = eval(input())
p = list(map(int, input().split()))
ps = sorted(p)
count = 0
for q, qs in zip(p, ps):
    if q != qs:
        count += 1
print(("YES" if count <= 2 else "NO"))

-d_p = [] -d_ps = [] -for i, q in enumerate(p): -    if q != ps[i]: -        d_p.append(q) -        d_ps.append(ps[i]) -if len(d_p) > 2: -    print("NO") -elif len(d_p) == 2: -    d_p.sort() -    if d_p == d_ps: -        print("YES") -    else: -        print("NO") -else: -    print("YES") +count = 0 +for q, qs in zip(p, ps): +    if q != qs: +        count += 1 +print(("YES" if count <= 2 else "NO"))