#include <stdio.h>
#define EXTREME 1000000000
#define MAX_ELEM 500000
int L[MAX_ELEM / 2];
int R[MAX_ELEM / 2];

int merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int cnt = 0;
    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] = EXTREME;
    R[n2] = EXTREME;

    /* compare with L and R */
    int 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;
        }
    }

    return cnt;
}

int merge_sort(int A[], int left, int right){
    int val1, val2, val3;
    if(right - left > 1){
        int mid = (right+left)/2;
        val1 = merge_sort(A, left, mid);
        val2 = merge_sort(A, mid, right);
        val3 = merge(A, left, mid, right);
        return val1+val2+val3;

    } else{
        return 0;
    }

}

int main(){
    int A[MAX_ELEM];
    int n;

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

    int result = merge_sort(A, 0, n);
    
    printf("%d\n", result);
    return 0;
}
