#include<stdio.h>
#define N 500000
#define M 2000000000

unsigned long long int cnt;
int L[N/2+2], R[N/2+2];

unsigned long long int merge(int A[], int left, int mid, int right){
    int n1, n2, i, j;
    cnt=0;
    n1 = mid - left; n2 = right - mid;

    for(i=0 ; i<n1 ; i++)   L[i] = A[left+i];
    for(i=0 ; i<n2 ; i++)   R[i] = A[mid+i];
    
    L[n1] = R[n2] = M;
    i=0; j=0;

    for(int k=left ; k<right ; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++; 
            cnt += n1 - i; //Lの要素の残りの数
        }
    }
    return cnt;
}

unsigned long long int  mergeSort(int A[], int left, int right){
    unsigned long long int v1, v2, v3;
    if(left+1<right){
        int mid = (left+right) / 2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1+v2+v3;
    }
    else return 0;
}


int main(void){
    int n, a[N];
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++)
        scanf("%d",&a[i]);
    cnt = mergeSort(a, 0, n);
    printf("%lld\n", cnt);
    return 0;
}

