import numpy as np



N = int(eval(input()))

p_raw = np.array(list(map(int, input().split())))

p_sort = np.sort(p_raw)



compare = (p_raw==p_sort)



if np.count_nonzero(compare == False) > 2:

  print('NO')

else:

  print('YES')
N = int(eval(input()))

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



p_sorted = sorted(p)



is_changed = [0 if x==y else 1 for x,y in zip(p, p_sorted)]



if sum(is_changed) <= 2:

    print("YES")

else:

    print("NO")
import numpy as np

N = int(eval(input()))
p_raw = np.array(list(map(int, input().split())))
p_sort = np.sort(p_raw)
compare = p_raw == p_sort
if np.count_nonzero(compare == False) > 2:
    print("NO")
else:
    print("YES")

N = int(eval(input()))
p = list(map(int, input().split()))
p_sorted = sorted(p)
is_changed = [0 if x == y else 1 for x, y in zip(p, p_sorted)]
if sum(is_changed) <= 2:
    print("YES")
else:
    print("NO")

-import numpy as np - -p_raw = np.array(list(map(int, input().split()))) -p_sort = np.sort(p_raw) -compare = p_raw == p_sort -if np.count_nonzero(compare == False) > 2: +p = list(map(int, input().split())) +p_sorted = sorted(p) +is_changed = [0 if x == y else 1 for x, y in zip(p, p_sorted)] +if sum(is_changed) <= 2: +    print("YES") +else: -else: -    print("YES")