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


int size;
int *S;
int *L;
int *R;
int cnt;

void merge(int left,int mid,int right){
  int i;
  int r,l;
  for(i=left;i<mid;i++) L[i-left]=S[i];
  L[mid-left]=INT_MAX;
  for(i=mid;i<right;i++) R[i-mid]=S[i];
  R[right-mid]=INT_MAX;
  l=r=0;
  for(i=left;i<right;i++){
    if(L[l]<R[r]){
      S[i]=L[l];
      l++;
    }
    else{
      cnt+=mid-left-l;
      S[i]=R[r];
      r++;
    }
  }
}


void m_sort(int left,int right){
  if(right <= left+1) return;
  int mid;
  mid=(left +right)/2;
  m_sort(left,mid);
  m_sort(mid,right);
  merge(left,mid,right);
}






int main(){
  scanf("%d",&size);
  S=malloc(size*sizeof(int));
  L=malloc(size*sizeof(int));
  R=malloc(size*sizeof(int));
  int i;
  for(i=0;i<size;i++){
    scanf("%d",&S[i]);
    S[i]--;
  }
  cnt=0;
  m_sort(0,size);
  printf("%d\n",cnt);
  return 0;
}

  
  