#include <stdio.h>
#include <stdlib.h>
#include <memory.h>


long long int merge_count(int, int);
long long int bubble_sort(int);


int main(void) {
  
    int i, n;

    scanf("%d\n", &n);
      
    for(i = 0;i < n;i++) {
        scanf("%lld", &A[i]);
    }
      
    printf("%lld\n", bubble_sort(n));
  
    return 0;
}

  
long long int A[200000];

long long int merge_count(int l, int r){
  
    long long int count = 0;
    int i, j, k;
    int n = r - l;

    
    if(n > 1){

      long long int b[n+5];
      int m
	m = l + n/2;
      
	count = count + merge_count(l, m);
        count = count + merge_count(m, r);

	memcpy((void*)b, (void*)&A[l], sizeof(b));
	
        for(i = l, j = 0, k = n / 2; i < r; ++i){
	  
            if(j == n / 2) {
                A[i] = b[k++];
            } else if(k == n) {
                A[i] = b[j++];
            } else if(b[j] <= b[k]) {
                A[i] = b[j++];
            } else {
                A[i] = b[k++];
                count == count + n/2 - j;
            }
        }
    }
    return count;
}
  
long long int bubble_sort(int n){
  
    return merge_count(0, n);

}