INF = float("inf")

cnt = 0

def merge(A, left, mid, right):

    global cnt

    L = A[left: mid] + [INF]

    R = A[mid: right] + [INF]

    i = j = 0

    limit = mid - left

    for k in range(left, right):

        if L[i] <= R[j]:

            A[k] = L[i]

            i += 1

            if i >= limit:

                A[k + 1: right] = R[j: -1]

                break

        else:

            cnt += limit - i

            A[k] = R[j]

            j += 1

def mergeSort(A, left, right):

    if left + 1 < right:

        mid = (left + right) // 2

        mergeSort(A, left, mid)

        mergeSort(A, mid, right)

        merge(A, left, mid, right)

n = int(eval(input()))

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

mergeSort(S, 0, n)

print(cnt)



INF = float("inf")

cnt = 0

def merge(A, left, mid, right):

    global cnt

    L = A[left: mid] + [INF]

    R = A[mid: right] + [INF]

    i = j = 0

    limit = mid - left

    for k in range(left, right):

        if L[i] <= R[j]:

            A[k] = L[i]

            i += 1

        else:

            cnt += limit - i

            A[k] = R[j]

            j += 1

def mergeSort(A, left, right):

    if left + 1 < right:

        mid = (left + right) // 2

        mergeSort(A, left, mid)

        mergeSort(A, mid, right)

        merge(A, left, mid, right)

n = int(eval(input()))

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

mergeSort(S, 0, n)

print(cnt)



INF = float("inf")
cnt = 0


def merge(A, left, mid, right):
    global cnt
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    i = j = 0
    limit = mid - left
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
            if i >= limit:
                A[k + 1 : right] = R[j:-1]
                break
        else:
            cnt += limit - i
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


n = int(eval(input()))
S = list(map(int, input().split()))
mergeSort(S, 0, n)
print(cnt)

INF = float("inf")
cnt = 0


def merge(A, left, mid, right):
    global cnt
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    i = j = 0
    limit = mid - left
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            cnt += limit - i
            A[k] = R[j]
            j += 1


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)


n = int(eval(input()))
S = list(map(int, input().split()))
mergeSort(S, 0, n)
print(cnt)

-            if i >= limit: -                A[k + 1 : right] = R[j:-1] -                break