N=int(eval(input()))

p=[int(i) for i in input().split()]

flag=1

for k in range(N-1):

    if p[k]>p[k+1]:

        flag=0

        break

if flag==1:

    print("YES")

    exit()

for i in range(N):

    for j in range(N):

        if i>=j:

            continue

        q=[p[i] for i in range(N)]

        q[i],q[j]=q[j],q[i]

        flag=1

        for k in range(N-1):

            if q[k]>q[k+1]:

                flag=0

                break

        if flag==1:

            print("YES")

            exit()

print("NO")

N=int(eval(input()))

p=[int(i) for i in input().split()]

tmp=0

for i in range(N):

    if p[i]!=i+1:

        tmp+=1

if tmp<=2:

    print("YES")

else:

    print("NO")

N = int(eval(input()))
p = [int(i) for i in input().split()]
flag = 1
for k in range(N - 1):
    if p[k] > p[k + 1]:
        flag = 0
        break
if flag == 1:
    print("YES")
    exit()
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        q = [p[i] for i in range(N)]
        q[i], q[j] = q[j], q[i]
        flag = 1
        for k in range(N - 1):
            if q[k] > q[k + 1]:
                flag = 0
                break
        if flag == 1:
            print("YES")
            exit()
print("NO")

N = int(eval(input()))
p = [int(i) for i in input().split()]
tmp = 0
for i in range(N):
    if p[i] != i + 1:
        tmp += 1
if tmp <= 2:
    print("YES")
else:
    print("NO")

-flag = 1 -for k in range(N - 1): -    if p[k] > p[k + 1]: -        flag = 0 -        break -if flag == 1: +tmp = 0 +for i in range(N): +    if p[i] != i + 1: +        tmp += 1 +if tmp <= 2: -    exit() -for i in range(N): -    for j in range(N): -        if i >= j: -            continue -        q = [p[i] for i in range(N)] -        q[i], q[j] = q[j], q[i] -        flag = 1 -        for k in range(N - 1): -            if q[k] > q[k + 1]: -                flag = 0 -                break -        if flag == 1: -            print("YES") -            exit() -print("NO") +else: +    print("NO")