#include <bits/stdc++.h>
using std::make_pair;
using std::pair;
using std::sort;
int n;
int s[205];
void swap(int *x, int *y) {
  int t = *y;
  *y = *x;
  *x = t;
}
void prt(int n) {
  for (int i = 0; i < n; ++i) printf("%d%c", s[i], i == n - 1 ? '\n' : ' ');
}
int main() {
  scanf("%d", &n);
  n <<= 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", s + i);
  }
  int ans = 0;
  for (int i = 0, j = 0;;) {
    while (s[i] == s[i + 1] && i < n) i += 2;
    while (s[n - 1 - j] == s[n - 2 - j] && i + j < n) j += 2;
    if (i + j >= n) break;
    if (i >= j) {
      int a = i + 1;
      for (; s[a] != s[i]; a++)
        ;
      for (; a != i + 1; a--, ans++) swap(s + a, s + a - 1);
    } else {
      int a = n - j - 2;
      for (; s[a] != s[n - 1 - j]; a--)
        ;
      for (; a != n - j - 2; a++, ans++) swap(s + a, s + a + 1);
    }
  }
  printf("%d", ans);
  return 0;
}
