#include <stdio.h>

int main() {
  int n, i, j, q, bin[200000], cnt = 0, max = 0;

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d", &q);
    bin[q] = i + 1;
    if(q > max)
      max = q;
  }

  for(i = 1;i <= max;i++) {
    if(bin[i] == 0)
      continue;
    for(j = i - 1;j >= 0;j--)
      if(bin[i] < bin[j])
        cnt++;
  }

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

  return 0;
}

