#include <bits/stdc++.h>
using namespace std;
vector<long long> v[201];
long long arr[201];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i, j, c, max1, min1, temp, temp1, n1;
  cin >> n;
  for (i = 0; i < 2 * n; i++) {
    cin >> arr[i];
    v[arr[i]].push_back(i);
  }
  for (i = 1; i <= n; i++) {
    if (abs(v[i][0] - v[i][1]) == 1) {
      continue;
    } else {
      break;
    }
  }
  if (i > n) {
    cout << "0";
    exit(0);
  }
  c = 0;
  while (1) {
    for (i = 0; i < 2 * n; i++) {
      if (abs(v[arr[i]][0] - v[arr[i]][1]) == 1) {
        continue;
      } else {
        max1 = max(v[arr[i]][0], v[arr[i]][1]);
        min1 = min(v[arr[i]][0], v[arr[i]][1]);
        c += max1 - min1 - 1;
        for (j = max1; j > min1 + 1; j--) {
          if (v[arr[j]][0] == j) {
            temp = 0;
          } else {
            temp = 1;
          }
          if (v[arr[j - 1]][0] == j - 1) {
            temp1 = 0;
          } else {
            temp1 = 1;
          }
          v[arr[j]][temp] = j - 1;
          v[arr[j - 1]][temp1] = j;
          swap(arr[j], arr[j - 1]);
        }
      }
    }
    for (i = 1; i <= n; i++) {
      if (abs(v[i][0] - v[i][1]) == 1) {
        continue;
      } else {
        break;
      }
    }
    if (i > n) {
      cout << c;
      exit(0);
    }
  }
}
