  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
      mcount += n1 - i;
    }
  }
  free(L);
  free(R);
  return mcount;
}


int mergeSort(int A[],int left,int right){
  int mid,a,b,c;
  if(left+1 < right){
    mid = (left + right) / 2;
    a = mergeSort(A,left,mid);
    b = mergeSort(A,mid,right);
    c = merge(A,left,mid,right);
    return a+b+c;
  }
  else return 0;
}

int main(){
  int i,n;
  int answer;

  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  answer = mergeSort(A,0,n);

  printf("%d\n",answer);

  return 0;

}