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

long int inversions = 0;

// merge merges the array from [left, middle) with [middle, right).
void merge(int *array, int left, int middle, int right)
{
  int *leftArray, *rightArray, i, j, k,
    leftSize = middle-left, rightSize = right-middle;
  leftArray = (int *) malloc(leftSize*sizeof(int));
  rightArray = (int *) malloc(rightSize*sizeof(int));
  // assign the values from array to the left and right arrays
  for ( i = 0; i < leftSize; i++ )
    leftArray[i] = array[left+i];
  for ( i = 0; i < rightSize; i++ )
    rightArray[i] = array[middle+i];
  i = 0; // leftArray index
  j = 0; // rightArray index
  // merge leftArray and rightArray
  for ( k = left; k < right; k++ )
    {
      // if we are at the end of the leftArray
      if ( i == leftSize )
	array[k] = rightArray[j++];
      // if we are at the end of the rightArray
      else if ( j == rightSize )
	array[k] = leftArray[i++];
      // if the leftArray contains the next element
      else if ( leftArray[i] <= rightArray[j] )
	array[k] = leftArray[i++];
      // if the rightArray contains the next element
      else
	{
	  array[k] = rightArray[j++];
	  inversions += leftSize-i;
	}
    }
  return;
}

// mergeSort recursively splits the array into smaller chunks and then
// merges those chunks.
void mergeSort(int *array, int left, int right)
{
  // only split the array if the piece isn't yet length 1
  if ( left+1 < right )
    {
      int middle = (left + right)/2;
      mergeSort(array, left, middle);
      mergeSort(array, middle, right);
      merge(array, left, middle, right);
    }
  return;
}

int main()
{
  int length, *array, i;
  // get input
  scanf(" %d", &length);
  array = (int *) malloc(length*sizeof(int));
  for ( i = 0; i < length; i++ )
    scanf(" %d", array+i);
  // sort the array using mergeSort
  mergeSort(array, 0, length);
  /* for ( i = 0; i < length; i++ ) */
  /*   printf("%d%c", array[i], i == length-1 ? '\n' : ' '); */
  // print the number of inversions
  printf("%d\n", inversions);
  return 0;
}

