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

long count=0;

typedef struct number{
  long num;
  struct number *left;
  struct number *right;
}Number;

Number *create(long a, Number *begin) {
  Number *p = (Number*)malloc(sizeof(Number));
  p->num = a;
  p->left = NULL;
  p->right = NULL;
  if(begin == NULL) {
    return p;
  }
  Number *p0 = begin;
  while(1) {
    if(a < p0->num) {
      count++;
      if(p0->left != NULL) {
	p0 = p0->left;
      }else{
	p0->left = p;
	break;
      }
    }else{
      if(p0->right != NULL) {
	p0 = p0->right;
      }else{
	p0->right = p;
	break;
      }
    }
  }
  return begin;
}

int main() {
  long i,n,a;
  Number *begin;
  scanf("%ld",&n);
  for(i = 0; i < n; i++) {
    scanf("%ld",&a);
    begin = create(a,begin);
  }
  printf("%ld\n",count);

  return 0;
}