#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
long *Array, *Work;
long Cnt,icount;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void mergesort(long first, long last)
{
	int middle;
	static long i, j, k, p, l;

	if (first < last) {
		middle = (first + last) / 2;
		mergesort(first, middle);
		mergesort(middle + 1, last);
		p = 0;
		for (i = first; i <= middle; i++) Work[p++] = Array[i];
		i = middle + 1;  j = 0;  k = first; l=i-k;
		while (i <= last && j < p){
			if (Work[j] <= Array[i]){
                Array[k++] = Work[j++];
                l--;
			}else{
                Array[k++] = Array[i++];
                Cnt+=l;
            }
        }
		while (j < p) Array[k++] = Work[j++];
	}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long n;

    fscanf(file, "%ld", &n);
    Array = malloc(succ(n)*sizeof(long));
    Work = malloc(succ(n/2)*sizeof(long));
    for (icount=Cnt=0; icount<n; icount++){
        fscanf(file, "%ld", &Array[icount]);
    }
    mergesort(0, pred(n));
    printf("%ld\n", Cnt);
    free(Array);
    free(Work);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif