#include <bits/stdc++.h>
using namespace std;
int n, fa[600005], siz1[600005], siz2[600005], height[600005];
struct node {
  int x, y, s1, s2, ds;
  long long rs;
} st[600005];
int tp;
long long res = 0;
map<pair<int, int>, int> mp;
vector<pair<int, int> > T[1200005];
inline int getf(int x) { return fa[x] == x ? x : getf(fa[x]); }
void merg(int x, int y) {
  x = getf(x), y = getf(y);
  if (x == y)
    return;
  else if (height[x] > height[y])
    swap(x, y);
  st[++tp] = (node){x, y, siz1[y], siz2[y], height[y], res},
  res -= 1ll * siz1[x] * siz2[x] + 1ll * siz1[y] * siz2[y];
  height[y] += height[x] == height[y], fa[x] = y, siz1[y] += siz1[x],
                                       siz2[y] += siz2[x],
                                       res += 1ll * siz1[y] * siz2[y];
}
void pop() {
  int x = st[tp].x;
  int y = st[tp].y;
  fa[x] = x;
  height[y] = st[tp].ds;
  siz1[y] = st[tp].s1;
  siz2[y] = st[tp].s2, res = st[tp].rs, tp--;
}
void back(int x) {
  while (tp > x) pop();
}
void modif(int x, int l, int r, int L, int R, pair<int, int> u) {
  if (l > R || L > r) return;
  if (L <= l && r <= R) {
    T[x].push_back(u);
    return;
  }
  modif(x << 1, l, (l + r) >> 1, L, R, u);
  modif(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, u);
}
void solve(int x, int l, int r) {
  int top = tp;
  for (int i = 0; i < (int)T[x].size(); i++) {
    int a = T[x][i].first;
    int b = T[x][i].second;
    merg(a, b);
  }
  if (l == r) {
    printf("%lld ", res);
    while (tp > top) pop();
    return;
  } else
    solve(x << 1, l, (l + r) >> 1), solve(x << 1 | 1, ((l + r) >> 1) + 1, r);
  while (tp > top) pop();
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    pair<int, int> p = make_pair(x, y + 300000);
    if (mp[p])
      modif(1, 1, n, mp[p], i - 1, p), mp.erase(p);
    else
      mp[p] = i;
  }
  for (int i = 1; i <= 600000; i++)
    fa[i] = i, (i <= 300000 ? siz1[i] : siz2[i]) = 1;
  for (auto i : mp) modif(1, 1, n, i.second, n, i.first);
  solve(1, 1, n);
  return 0;
}
