#include <bits/stdc++.h>
using namespace std;
int temp[100005];
int arr[100005];
int pos[100005];
int shift[100005];
bool visPos[100005];
bool done[100005];
int main() {
  int n;
  scanf("%d", &n);
  n *= 2;
  for (int i = 1; i <= n; i++) scanf("%d", &temp[i]);
  for (int i = 1; i <= n; i++) {
    if (!done[temp[i]]) {
      arr[i] = (temp[i] * 2) - 1;
      done[temp[i]] = true;
    } else
      arr[i] = temp[i] * 2;
  }
  for (int i = 1; i <= n; i++) pos[arr[i]] = i;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (visPos[i]) continue;
    int target;
    if (arr[i] % 2 == 0)
      target = arr[i] - 1;
    else
      target = arr[i] + 1;
    int curPos = i;
    int targetPos = pos[target];
    ans += targetPos - curPos - 1;
    visPos[i + 1] = true;
    for (int j = targetPos; j >= curPos + 2; j--) {
      swap(arr[j], arr[j - 1]);
    }
    for (int j = targetPos; j >= i + 2; j--) {
      pos[arr[j]]++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
