import copy

n=int(eval(input()))

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

chk=sorted(numl)



flag=True

if chk==numl :

  flag=True

else :

  flag=False



for i in range(n) :

  #print(i)

  for j in range(n):

    #print(j)

    temp=copy.deepcopy(numl)

    temp[i]=numl[j]

    temp[j]=numl[i]

    #print(temp)

    if temp==chk :

      flag=True

      break



if flag==True:

  print("YES")

else :

  print("NO")

  











n=int(eval(input()))

#a,b=map(int,input().split())

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

#l=[list(map(int,input().split())) for i in range(n)]

#sortedl=sorted(pl)

flag=False

if pl==sorted(pl):

    flag=True

else:

    for i in range(n):

        for j in range(n):

            templ=pl[:]

            templ[i]=pl[j]

            templ[j]=pl[i]

            if templ==(sorted(pl)):

                flag=True

                break

if flag:

    print("YES")

else:

    print("NO")
import copy

n = int(eval(input()))
numl = list(map(int, input().split()))
chk = sorted(numl)
flag = True
if chk == numl:
    flag = True
else:
    flag = False
for i in range(n):
    # print(i)
    for j in range(n):
        # print(j)
        temp = copy.deepcopy(numl)
        temp[i] = numl[j]
        temp[j] = numl[i]
        # print(temp)
        if temp == chk:
            flag = True
            break
if flag == True:
    print("YES")
else:
    print("NO")

n = int(eval(input()))
# a,b=map(int,input().split())
pl = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
# sortedl=sorted(pl)
flag = False
if pl == sorted(pl):
    flag = True
else:
    for i in range(n):
        for j in range(n):
            templ = pl[:]
            templ[i] = pl[j]
            templ[j] = pl[i]
            if templ == (sorted(pl)):
                flag = True
                break
if flag:
    print("YES")
else:
    print("NO")

-import copy - -numl = list(map(int, input().split())) -chk = sorted(numl) -flag = True -if chk == numl: +# a,b=map(int,input().split()) +pl = list(map(int, input().split())) +# l=[list(map(int,input().split())) for i in range(n)] +# sortedl=sorted(pl) +flag = False +if pl == sorted(pl): -    flag = False -for i in range(n): -    # print(i) -    for j in range(n): -        # print(j) -        temp = copy.deepcopy(numl) -        temp[i] = numl[j] -        temp[j] = numl[i] -        # print(temp) -        if temp == chk: -            flag = True -            break -if flag == True: +    for i in range(n): +        for j in range(n): +            templ = pl[:] +            templ[i] = pl[j] +            templ[j] = pl[i] +            if templ == (sorted(pl)): +                flag = True +                break +if flag: