#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7, mod = 4e5;
int n;
int dsu[MAXN * 4];
long long siz[MAXN * 4], nowans;
long long save[MAXN * 4][9], cnts;
int find(int A) { return dsu[A] == A ? A : find(dsu[A]); }
int getsiz(int A) { return siz[A] % mod + siz[A] / mod; }
void add_point(int x, int y) {
  int u1 = find(x), v1 = find(6e5 + y);
  int u2 = find(3e5 + y), v2 = find(9e5 + x);
  if (u1 != v1) {
    ++cnts;
    save[cnts][8] = nowans;
    nowans -= (siz[v1] % mod) * (siz[v1] / mod);
    nowans -= (siz[v2] % mod) * (siz[v2] / mod);
    if (getsiz(u1) > getsiz(v1)) swap(u1, v1);
    if (getsiz(u2) > getsiz(v2)) swap(u2, v2);
    save[cnts][0] = u1;
    save[cnts][1] = v1;
    save[cnts][2] = dsu[u1];
    save[cnts][3] = siz[v1];
    save[cnts][4] = u2;
    save[cnts][5] = v2;
    save[cnts][6] = dsu[u2];
    save[cnts][7] = siz[v2];
    dsu[u1] = v1;
    siz[v1] += siz[u1];
    dsu[u2] = v2;
    siz[v2] += siz[u2];
    nowans += (siz[v1] % mod) * (siz[v2] % mod);
  }
}
void del_point() {
  dsu[save[cnts][0]] = save[cnts][2];
  siz[save[cnts][1]] = save[cnts][3];
  dsu[save[cnts][4]] = save[cnts][6];
  siz[save[cnts][5]] = save[cnts][7];
  nowans = save[cnts][8];
  --cnts;
}
pair<int, int> dots[MAXN];
map<pair<int, int>, int> Map;
long long ans[MAXN];
vector<int> change[MAXN * 6];
void add(int L, int R, int X, int l = 1, int r = n, int now = 1) {
  if (L > r || R < l || L > R) return;
  if (L <= l && R >= r) {
    change[now].push_back(X);
    return;
  }
  int mid = (l + r) >> 1;
  add(L, R, X, l, mid, now << 1);
  add(L, R, X, mid + 1, r, now << 1 | 1);
}
void dfs(int l = 1, int r = n, int now = 1) {
  int in = cnts;
  for (auto i : change[now]) add_point(dots[i].first, dots[i].second);
  if (l == r)
    ans[l] = nowans;
  else {
    int mid = (l + r) >> 1;
    dfs(l, mid, now << 1);
    dfs(mid + 1, r, now << 1 | 1);
  }
  while (cnts != in) del_point();
}
int main() {
  for (int i = 1; i <= 6e5; i++) siz[i] = 1;
  for (int i = 1; i <= 6e5; i++) siz[600000 + i] = mod;
  for (int i = 1; i <= 1.2e6; i++) dsu[i] = i;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> dots[i].first >> dots[i].second;
    if (Map.find(dots[i]) != Map.end()) {
      add(Map[dots[i]], i - 1, Map[dots[i]]);
      Map.erase(dots[i]);
    } else
      Map[dots[i]] = i;
  }
  for (auto i : Map) add(i.second, n, i.second);
  dfs();
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
