#include <bits/stdc++.h>
using namespace std;
int n, rs;
int a[2 * 1000], x[1000];
int Left[1000], Right[1000];
void Swap(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}
void Init() {
  cin >> n;
  for (int i = 1; i <= n; i++) Left[i] = 0;
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", &a[i]);
    if (Left[a[i]] == 0) {
      Left[a[i]] = i;
      x[i] = 1;
    } else {
      Right[a[i]] = i;
      x[i] = 2;
    }
  }
}
void Solve() {
  for (int i = 1; i <= 2 * n; i++) {
    if (x[i] == 1) {
      rs += Right[a[i]] - Left[a[i]] - 1;
      int tmp = a[Right[a[i]]], tmpX = x[Right[a[i]]];
      for (int j = Right[a[i]]; j > Left[a[i]] + 1; j--) {
        a[j] = a[j - 1];
        x[j] = x[j - 1];
      }
      a[Left[a[i]] + 1] = tmp;
      x[Left[a[i]] + 1] = tmpX;
      for (int j = Left[a[i]] + 2; j <= Right[a[i]]; j++) {
        if (x[j] == 1) {
          Left[a[j]]++;
        } else {
          Right[a[j]]++;
        }
      }
      Right[a[i]] = Left[a[i]] + 1;
    }
  }
  cout << rs << endl;
}
int main() {
  Init();
  Solve();
  return 0;
}
