import copy





def actual(n, P):

    nums_asc = sorted(P)



    if nums_asc == P:

        return 'YES'



    N = len(P)

    for i in range(N):

        for j in range(1, N):

            swapped_nums = copy.deepcopy(P)



            swapped_nums[i] = P[j]

            swapped_nums[j] = P[i]



            if swapped_nums == nums_asc:

                return 'YES'



    return 'NO'



n = int(eval(input()))

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



print((actual(n, P)))
def actual(n, P):

    # 正しくない配置にある数字が2つ以下なら、1回以下のSwapで照準になる

    n_unmatched = [i == p for i, p in enumerate(P, start=1)].count(False)



    if n_unmatched <= 2:

        return 'YES'



    return 'NO'





n = int(eval(input()))

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



print((actual(n, P)))
import copy


def actual(n, P):
    nums_asc = sorted(P)
    if nums_asc == P:
        return "YES"
    N = len(P)
    for i in range(N):
        for j in range(1, N):
            swapped_nums = copy.deepcopy(P)
            swapped_nums[i] = P[j]
            swapped_nums[j] = P[i]
            if swapped_nums == nums_asc:
                return "YES"
    return "NO"


n = int(eval(input()))
P = list(map(int, input().split()))
print((actual(n, P)))

def actual(n, P):
    # 正しくない配置にある数字が2つ以下なら、1回以下のSwapで照準になる
    n_unmatched = [i == p for i, p in enumerate(P, start=1)].count(False)
    if n_unmatched <= 2:
        return "YES"
    return "NO"


n = int(eval(input()))
P = list(map(int, input().split()))
print((actual(n, P)))

-import copy - - -    nums_asc = sorted(P) -    if nums_asc == P: +    # 正しくない配置にある数字が2つ以下なら、1回以下のSwapで照準になる +    n_unmatched = [i == p for i, p in enumerate(P, start=1)].count(False) +    if n_unmatched <= 2: -    N = len(P) -    for i in range(N): -        for j in range(1, N): -            swapped_nums = copy.deepcopy(P) -            swapped_nums[i] = P[j] -            swapped_nums[j] = P[i] -            if swapped_nums == nums_asc: -                return "YES"