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

long count=0;

typedef struct number{
  long num;
  struct number *next;
}Number;

Number *create(long a, Number *begin) {
  Number *p = (Number*)malloc(sizeof(Number));
  p->num = a;
  p->next = NULL;
  if(begin == NULL) {
    return p;
  }
  if(begin->num < a) {
    p->next = begin;
    return p;
  }
  count++;
  Number *p0 = begin;
  while(p0->next != NULL) {
    if(p0->next->num < a) break;
    p0=p0->next;
    count++;
  }
  p0->next = p;
  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;
}