import copy



n = int(eval(input()))

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



if all([li[i] < li[i+1] for i in range(n-1)]):

    print('YES')

    exit()

for i in range(n):

    for j in range(i+1,n):

        a = copy.copy(li)

        a[i],a[j] = a[j],a[i]

        if all([a[i] < a[i+1] for i in range(n-1)]):

            print('YES')

            exit()



print('NO')

n = int(eval(input()))

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



count = 0



for i in range(n):

    if li[i] != i+1:

        count += 1

if count <= 2:

    print('YES')

else:

    print('NO')

import copy

n = int(eval(input()))
li = list(map(int, input().split()))
if all([li[i] < li[i + 1] for i in range(n - 1)]):
    print("YES")
    exit()
for i in range(n):
    for j in range(i + 1, n):
        a = copy.copy(li)
        a[i], a[j] = a[j], a[i]
        if all([a[i] < a[i + 1] for i in range(n - 1)]):
            print("YES")
            exit()
print("NO")

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

-import copy - -if all([li[i] < li[i + 1] for i in range(n - 1)]): +count = 0 +for i in range(n): +    if li[i] != i + 1: +        count += 1 +if count <= 2: -    exit() -for i in range(n): -    for j in range(i + 1, n): -        a = copy.copy(li) -        a[i], a[j] = a[j], a[i] -        if all([a[i] < a[i + 1] for i in range(n - 1)]): -            print("YES") -            exit() -print("NO") +else: +    print("NO")