def inpl(): return list(map(int, input().split()))



N = int(eval(input()))

P = inpl()

Q = sorted(P)



OK = False

for i in range(N):

    for j in range(N):

        P[i], P[j] = P[j], P[i]

        if P == Q:

            OK = True

        P[i], P[j] = P[j], P[i]

print(("YES" if OK else "NO"))
def inpl(): return list(map(int, input().split()))



N = int(eval(input()))

P = inpl()

Q = sorted(P)



for i in range(N):

    for j in range(i, N):

        R = [p for p in P]

        R[i], R[j] = R[j], R[i]

        for k in range(N):

            if R[k] != Q[k]:

                break

        else:

            print("YES")

            exit()

else:

    print("NO")
def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
P = inpl()
Q = sorted(P)
OK = False
for i in range(N):
    for j in range(N):
        P[i], P[j] = P[j], P[i]
        if P == Q:
            OK = True
        P[i], P[j] = P[j], P[i]
print(("YES" if OK else "NO"))

def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
P = inpl()
Q = sorted(P)
for i in range(N):
    for j in range(i, N):
        R = [p for p in P]
        R[i], R[j] = R[j], R[i]
        for k in range(N):
            if R[k] != Q[k]:
                break
        else:
            print("YES")
            exit()
else:
    print("NO")

-OK = False -    for j in range(N): -        P[i], P[j] = P[j], P[i] -        if P == Q: -            OK = True -        P[i], P[j] = P[j], P[i] -print(("YES" if OK else "NO")) +    for j in range(i, N): +        R = [p for p in P] +        R[i], R[j] = R[j], R[i] +        for k in range(N): +            if R[k] != Q[k]: +                break +        else: +            print("YES") +            exit() +else: +    print("NO")