#include <bits/stdc++.h>
using namespace std;
int a[201], p[201], vis[201];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int o = 0; o < 100; o++) {
    for (int i = 1; i < 101; i++) {
      vis[i] = 0;
    }
    for (int i = 1; i <= 2 * n; i++) {
      if (vis[a[i]] != 0) {
        if (a[i] == 2) {
        }
        p[i] = vis[a[i]];
        p[vis[a[i]]] = i;
      }
      vis[a[i]] = i;
    }
    int x = 0, y = 0, mx = 0, mxi = 0, my = 0, myi = 0, omn = 0, xx, yy, di = 0;
    bool d = 0;
    int dd[100010];
    for (int i = 1; i <= n; i++) dd[i] = 0;
    vector<int> v;
    for (int i = 1; i <= 2 * n; i++) {
      if (!dd[a[i]]) v.push_back(a[i]);
      dd[a[i]] = 1;
    }
    for (int i = 1; i <= n; i++) dd[i] = 0;
    for (int i, oo = 0; oo < n; oo++) {
      i = v[oo];
      x = 0;
      y = 0;
      int r = vis[i];
      int l = p[r];
      for (int j = l + 1; j < r; j++) {
        int u = a[j];
        if (p[vis[u]] < l) x++;
        if (vis[u] < l) x++;
      }
      for (int j = r - 1; j > l; j--) {
        int u = a[j];
        if (p[vis[u]] > r) y++;
        if (vis[u] > r) y++;
      }
      if ((x == 0 || y == 0) && abs(x - y) >= omn) {
        if (x == y) {
          if (l != r - 1) {
            d = 1;
            di = i;
          }
        }
        omn = abs(x - y);
        xx = x;
        yy = y;
        mxi = i;
        myi = i;
      }
    }
    if (omn != 0 || d)
      if (xx >= yy) {
        if (d) mxi = di;
        for (int j = p[vis[mxi]]; j < vis[mxi] - 1; j++) {
          int t = a[j];
          a[j] = a[j + 1];
          a[j + 1] = t;
          cnt++;
        }
      } else {
        for (int j = vis[mxi] - 1; j > p[vis[mxi]]; j--) {
          int t = a[j];
          a[j] = a[j + 1];
          a[j + 1] = t;
          cnt++;
        }
      }
  }
  cout << cnt;
  return 0;
}
