#include<stdio.h>
#include<stdlib.h>
int msort(int, int, int*);
main()
{
        int i, n, *a;
        scanf("%d", &n);
        a = (int*)malloc(sizeof(int) * n);
        for (i = 0; i < n; i++) {
                scanf("%d", &a[i]);
        }
        printf("%lld\n", msort(0, n - 1, a));
        free(a);
}
long long int msort(int left, int right, int *a)
{
        int i, j, center, num, base, work[right - left + 1];
        long long int reverse = 0;
        if (left >= right) return 0;
        center = (left + right) / 2;
        reverse += msort(left, center, a);
        reverse += msort(center + 1, right, a);
        for (num = 0, i = left; i <= center; num++, i++) {
                work[num] = a[i];
        }
        j = 0, base = left;
        while (i <= right && j < num) {
                if (a[i] < work[j]) {
                        a[base++] = a[i++];
                        reverse += i - base;
                } else {
                        a[base++] = work[j++];
                }
        }
        while (j < num) {
                a[base++] = work[j++];
        }
        return reverse;
}
