#define N 200005
#define INF 2000000000
#include <stdio.h>
int A[N];
int L[N / 2 + 2], R[N / 2 + 2];

long long merge(int A[], int left, int mid, int right) {
    long long cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    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] = INF;
    R[n2] = INF;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
            cnt += n1 - i;  //这一步是整个算法的精髓
        }
    }
    return cnt;
}

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

int main() {
    long long cnt = 0;
    int n = 0;
    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;
}
