import numpy as np



n = int(eval(input()))

p = np.array([int(_) for _ in input().split()])

pp = sorted(p)

dif = pp - p

non_zero = len(p)-np.count_nonzero(dif==0)

if (non_zero == 2) or (non_zero == 0):

    print("YES")

else:

    print("NO")
n = int(eval(input()))

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



dif = 0

for idx, pp in enumerate(p, 1):  # 1からidx

    dif += (idx != pp)

if dif <= 2:

    print("YES")

else:

    print("NO")
import numpy as np

n = int(eval(input()))
p = np.array([int(_) for _ in input().split()])
pp = sorted(p)
dif = pp - p
non_zero = len(p) - np.count_nonzero(dif == 0)
if (non_zero == 2) or (non_zero == 0):
    print("YES")
else:
    print("NO")

n = int(eval(input()))
p = [int(_) for _ in input().split()]
dif = 0
for idx, pp in enumerate(p, 1):  # 1からidx
    dif += idx != pp
if dif <= 2:
    print("YES")
else:
    print("NO")

-import numpy as np - -p = np.array([int(_) for _ in input().split()]) -pp = sorted(p) -dif = pp - p -non_zero = len(p) - np.count_nonzero(dif == 0) -if (non_zero == 2) or (non_zero == 0): +p = [int(_) for _ in input().split()] +dif = 0 +for idx, pp in enumerate(p, 1):  # 1からidx +    dif += idx != pp +if dif <= 2: