#include <bits/stdc++.h>
using namespace std;
const int INF = 100 * 1000 * 10000 + 228;
const int MOD = 1000 * 1000 * 1000 + 7;
vector<int> t, a, p;
int reloc_t(int v) { t[v] = t[v * 2 + 1] + t[v * 2]; }
void push_t(int v, int l, int r) {
  if (p[v] == 0) {
    return;
  }
  t[v] = p[v] * (r - l);
  if (r - l > 1) {
    p[2 * v] = p[v];
    p[2 * v + 1] = p[v];
  }
  p[v] = INF;
}
void build_t(int v, int l, int r) {
  p[v] = INF;
  if (r - l == 1) {
    t[v] = a[l];
    return;
  }
  build_t(v * 2 + 1, (l + r) / 2, r);
  build_t(v * 2, l, (r + l) / 2);
  reloc_t(v);
}
int get_t(int v, int l, int r, int L, int R) {
  push_t(v, l, r);
  if (r <= L || l >= R) {
    return 0;
  }
  if (L <= l && r <= R) {
    return t[v];
  }
  return get_t(v * 2, l, (l + r) / 2, L, R) +
         get_t(v * 2 + 1, (l + r) / 2, r, L, R);
}
void upd_t(int v, int l, int r, int L, int R, int x) {
  push_t(v, l, r);
  if (r <= L || l > L) {
    return;
  }
  if (L <= l && r <= R) {
    p[v] = x;
    push_t(v, l, r);
    return;
    ;
  }
  upd_t(v * 2, l, (l + r) / 2, L, R, x);
  upd_t(v * 2 + 1, (l + r) / 2, r, L, R, x);
  reloc_t(v);
}
bool check(vector<int> v) {
  for (int i = 0; i < v.size(); ++i) {
    if (!((i != v.size() - 1 && (v[i] == v[i + 1])) ||
          (i != 0 && v[i] == v[i - 1]))) {
      return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(2 * n);
  for (int i = 0; i < 2 * n; ++i) {
    cin >> v[i];
  }
  n *= 2;
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = i - 1; j >= 0; --j) {
      if (v[j] == v[i]) {
        ans += i - j - 1;
        v.erase(v.begin() + j);
        break;
      }
    }
  }
  cout << ans;
}
