from collections import deque

def mergeSort(A,left,right):



    middle = (left + right) // 2

    if left + 1 < right:

        mergeSort(A, left, middle)

        mergeSort(A, middle, right)

        merge(A,left,right,middle)

    

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

    global count

        

    L = deque(A[left:middle])

    R = deque(A[middle:right])

    L.append(float("inf"))

    R.append(float("inf"))

    for i in range(left,right):

        

        if L[0] < R[0]:

            A[i] = L.popleft()

        else:

            A[i] = R.popleft()

            count += len(L) -1 

count = 0     

eval(input())

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

mergeSort(A,0,len(A))

print(count)
from _collections import deque



SENIAL = 1000000000

def mergeSort(A,left,right):

    if left + 1 < right:

        middle = (left + right) // 2

        mergeSort(A, left, middle)

        mergeSort(A, middle, right)

        merge(A,left,right,middle)

    

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

    global count        

    L = deque(A[left:middle])

    R = deque(A[middle:right])

    L.append(SENIAL)

    R.append(SENIAL)

    for i in range(left,right):

        if L[0] < R[0]:

            A[i] = L.popleft()

        else:

            A[i] = R.popleft()

            count += len(L) -1 

count = 0     

eval(input())

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

mergeSort(A,0,len(A))

print(count)
from collections import deque


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


def merge(A, left, right, middle):
    global count
    L = deque(A[left:middle])
    R = deque(A[middle:right])
    L.append(float("inf"))
    R.append(float("inf"))
    for i in range(left, right):
        if L[0] < R[0]:
            A[i] = L.popleft()
        else:
            A[i] = R.popleft()
            count += len(L) - 1


count = 0
eval(input())
A = list(map(int, input().split()))
mergeSort(A, 0, len(A))
print(count)

from _collections import deque

SENIAL = 1000000000


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


def merge(A, left, right, middle):
    global count
    L = deque(A[left:middle])
    R = deque(A[middle:right])
    L.append(SENIAL)
    R.append(SENIAL)
    for i in range(left, right):
        if L[0] < R[0]:
            A[i] = L.popleft()
        else:
            A[i] = R.popleft()
            count += len(L) - 1


count = 0
eval(input())
A = list(map(int, input().split()))
mergeSort(A, 0, len(A))
print(count)

-from collections import deque +from _collections import deque + +SENIAL = 1000000000 -    middle = (left + right) // 2 +        middle = (left + right) // 2 -    L.append(float("inf")) -    R.append(float("inf")) +    L.append(SENIAL) +    R.append(SENIAL)