#include <stdio.h>
#include <string.h>
#include <math.h>



#define SENT 1000000000


int merge(int A[], int first, int mid, int last, int* ans){
    
    int i,j,k, former, latter, *L, *R, cmp;
    cmp = 0;
    
    
    former = mid - first + 1;
    latter = last - mid;
    
    L = (int*)malloc(sizeof(int) * (former+1));
    R = (int*)malloc(sizeof(int) * (latter+1));
    
    for (i=0; i < former; i++) {
        L[i] = A[first + i];
    }
    L[former] = SENT;
    
    for (i=0; i < latter; i++) {
        R[i] = A[i + mid + 1];
    }
    R[latter] = SENT;
    
    j=k=0;
    for (i = first; i < last + 1; i++) {
        if (L[j] <= R[k]) {
            A[i] = L[j];
            j++;
        }
        else
        {
            A[i] = R[k];
            k++;
            (*ans) += (former - j);
        }
        cmp += 1;
    }
    return cmp;
    
}

int MergeSort(int A[], int first, int last, int *ans){
    
    int cmp, mid;
    cmp = 0;
    
    if (first < last) {
        mid = (first + last)/2;
        cmp += MergeSort(A, first, mid, ans);
        cmp += MergeSort(A, mid+1, last, ans);
        cmp += merge(A, first, mid, last, ans);
    }
    
    return cmp;
}

int main( ){
    
    int i, n, ans = 0;
    
    scanf("%d", &n);
    int A[n];
    
    
    for (i=0; i<n; i++) {
        scanf("%d", &A[i]);
    }
    
    MergeSort(A, 0, n-1, &ans);
    
    printf("%d\n", ans);
    
    
    return 0;
}