N=int(eval(input()))

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



counter=0

for i in range(N):

  if p[i]!=int(i+1):

    counter+=1

    

if counter==0 or counter==2:

  print('YES')

else:

  print('NO')
import numpy as np



N=int(eval(input()))

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

q=np.arange(N)+1



temp=np.sum(~(p==q))

if temp==0 or temp==2:

  print('YES')

else:

  print('NO')

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

import numpy as np

N = int(eval(input()))
p = np.array(list(map(int, input().split())))
q = np.arange(N) + 1
temp = np.sum(~(p == q))
if temp == 0 or temp == 2:
    print("YES")
else:
    print("NO")

+import numpy as np + -p = list(map(int, input().split())) -counter = 0 -for i in range(N): -    if p[i] != int(i + 1): -        counter += 1 -if counter == 0 or counter == 2: +p = np.array(list(map(int, input().split()))) +q = np.arange(N) + 1 +temp = np.sum(~(p == q)) +if temp == 0 or temp == 2: