/* 学籍番号 17D8101029G 石塚 博之 ID: mcatpolo 言語:C */
#include <stdio.h>
#include <math.h>
#define N 200000

long a[N];

long merge(int left, int mid, int right){
    long c = 0;
    long L[N/2+2], R[N/2+2];
    int n1, n2, i, j, k;

    n1 = mid - left;
    n2 = right - mid;

   for(i=0; i<n1; i++){
       L[i] = a[left+i];
   }

   for(i=0; i<n2; i++){
       R[i] = a[mid + i];
   }

   L[n1] = (long)INFINITY;
   R[n2] = (long)INFINITY;

   i=0;
   j=0;

   for(k=left; k<right; k++){
       if(L[i] <= R[j]) {
           a[k] = L[i];
           i++;
       }
       else {
           a[k] = R[j];
           j++;
           c += n1 - i;
       }
   }

   return c;
}

long mergeSort(int left, int right){
    int mid;
    long v1, v2, v3;
    if (left + 1 < right)
    {
        mid = (left+right)/2;
        v1 = mergeSort(left, mid);
        v2 = mergeSort(mid, right);
        v3 = merge(left, mid, right);

        return v1 + v2 + v3;
    }

    return 0;
}

int main(void){
    long i;
    long n;

    scanf("%ld", &n);

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

   

   printf("%ld\n", mergeSort(0, n));

   return 0;
}
