#include <stdio.h>
#define N 200001
#define SENTINEL 100000000

int A[N];

long long merge(int left, int mid, int right) {

    long long cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    int i, j, k;

    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] = SENTINEL;
    i = j = 0;

    for(k = left; k < right; k++) {
        if(L[i] <= R[j]) A[k] = L[i++];
        else {
            A[k] = R[j++];
            cnt += (long long)(n1 - i);
        }
    }
    return cnt;
}

long long mergeSort(int left, int right) {
    int mid;
    long long cnt = 0;

    if(right - left <= 1) return;

    mid = (left + right) / 2;
    cnt += mergeSort(left, mid);
    cnt += mergeSort(mid, right);
    cnt += merge(left, mid, right);
    return cnt;
}


int main() {

    int i, n;
    int left, right;

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

    left = 0;
    right = n;

    printf("%ld\n", mergeSort(left, right));

    return 0;
}