#include<stdio.h>

#define N 2000000000

int n;
long long count=0;
int A[500000];

long long merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    for(int i=0; i<n1; i++){
        L[i] = A[left+i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid+i];
    }
    L[n1]=N;
    R[n2]=N;
    int i=0;
    int 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++;
            count += n1-i;
        }
    }

    return count;
}

long long mergeaSort(int A[], int left, int right){
    int mid;
    long long n1, n2, n3;
    if(left+1 < right){
        mid = (left+right)/2;
        n1=mergeaSort(A, left, mid);
        n2=mergeaSort(A, mid, right);
        n3=merge(A, left, mid, right);

        return n1+n2+n3;
    }
    else{
        return 0;
    }
}

int main(void){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    mergeaSort(A, 0, n);

    
    printf("%lld\n", count);

    return 0;
}
