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

#define N 200000
 
unsigned int a[N];
 
int L[N/2 + 2], R[N/2 + 2];

long long merge_sort(int*, int, int); 




int main(int argc, char** argv){
  
  int i = 0;
  int n;

  
   scanf("%d", &n);
 
   for(i; i < n; i++){
    scanf("%d", &a[i]);
   }
 
 
 printf("%lld\n", merge_sort(a, 0, n-1));
 
  return 0;
}



long long merge_sort(int *a, int l, int r){
  
  int m  = (l+r)/2;
  int count;
  int i, j;
  int n1, n2;
  long long v1, v2;
  int cnt = 0;

  if(l == r)
   return 0;

  
  v1 = merge_sort(a, l, m);
  v2 = merge_sort(a, m + 1, r);

  n1 = m-l+1;
  n2 = r - m;

  L[n1]  = R[n2] = 2000000000;

  for(count = l; count <= m; count++){
     L[count - l] = a[count];
  }
  
  for(count = m + 1; count <= r; count++){
    R[count - m - 1] = a[count];
  }
  
  for(i = 0, j = 0, count = l; count <= r; count++){

    if(L[i] <= R[j]){
     a[count] = L[i++];
    }
    
    else{
     a[count] = R[j++];
     cnt = cnt + n1 - i;
    }
 
  }
 
   return cnt + v1 + v2;
}
 



/*
#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);

}
 
*/ 


 
 
 
	   	
 