#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
inline int readint() {
  int res = 0, f = 1;
  char c = 0;
  while (!isdigit(c)) {
    c = getchar();
    if (c == '-') f = -1;
  }
  while (isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res * f;
}
int n, fa[MAXN * 2], size[MAXN * 2][2];
long long nowans;
struct Info {
  int type, idx, fa, size0, size1;
  Info(int t = 0, int a = 0, int b = 0, int c = 0, int d = 0) {
    type = t, idx = a, fa = b, size0 = c, size1 = d;
  }
};
inline int getFather(int v) { return fa[v] == v ? v : getFather(fa[v]); }
inline void merge(int x, int y, vector<Info> &s) {
  int fx = getFather(x), fy = getFather(y);
  if (fx == fy) return;
  nowans += 1ll * size[fx][0] * size[fy][1] + 1ll * size[fx][1] * size[fy][0];
  if (size[fx][0] + size[fx][1] < size[fy][0] + size[fy][1]) {
    s.push_back(Info(0, fx, fa[fx], 0, 0));
    s.push_back(Info(1, fy, 0, size[fy][0], size[fy][1]));
    fa[fx] = fy, size[fy][0] += size[fx][0], size[fy][1] += size[fx][1];
  } else {
    s.push_back(Info(0, fy, fa[fy], 0, 0));
    s.push_back(Info(1, fx, 0, size[fx][0], size[fx][1]));
    fa[fy] = fx, size[fx][0] += size[fy][0], size[fx][1] += size[fy][1];
  }
}
inline void undo(vector<Info> &s) {
  while (!s.empty()) {
    Info now = s[s.size() - 1];
    if (now.type == 0)
      fa[now.idx] = now.fa;
    else {
      int s0 = now.size0, s1 = now.size1;
      nowans -= 1ll * size[now.idx][0] * size[now.idx][1];
      nowans += 1ll * s0 * s1 +
                1ll * (size[now.idx][0] - s0) * (size[now.idx][1] - s1);
      size[now.idx][0] = s0, size[now.idx][1] = s1;
    }
    s.pop_back();
  }
}
struct Node {
  vector<pair<int, int> > op;
  vector<Info> s;
  Node() { op.clear(), s.clear(); }
} t[MAXN << 2];
long long ans[MAXN];
inline void modify(int id, int ql, int qr, int l, int r, pair<int, int> d) {
  if (ql == l && qr == r) {
    t[id].op.push_back(d);
    return;
  }
  int mid = (ql + qr) >> 1;
  if (r <= mid)
    modify(id << 1, ql, mid, l, r, d);
  else if (l > mid)
    modify(id << 1 | 1, mid + 1, qr, l, r, d);
  else
    modify(id << 1, ql, mid, l, mid, d),
        modify(id << 1 | 1, mid + 1, qr, mid + 1, r, d);
}
inline void dfs(int id, int ql, int qr) {
  for (int i = 0; i < t[id].op.size(); i++) {
    merge(t[id].op[i].first, t[id].op[i].second + 300000, t[id].s);
  }
  if (ql != qr) {
    int mid = (ql + qr) >> 1;
    dfs(id << 1, ql, mid), dfs(id << 1 | 1, mid + 1, qr);
  } else
    ans[ql] = nowans;
  undo(t[id].s);
}
map<pair<int, int>, int> tim;
map<pair<int, int>, int>::iterator it;
int main() {
  n = readint();
  for (int i = 1; i <= 300000; i++) fa[i] = i, size[i][0] = 1, size[i][1] = 0;
  for (int i = 300001; i <= 600000; i++)
    fa[i] = i, size[i][0] = 0, size[i][1] = 1;
  for (int i = 1; i <= n; i++) {
    int x = readint(), y = readint();
    pair<int, int> now = make_pair(x, y);
    if (tim.find(now) != tim.end())
      modify(1, 1, n, tim[now], i - 1, now), tim.erase(now);
    else
      tim[now] = i;
  }
  for (it = tim.begin(); it != tim.end(); it++)
    modify(1, 1, n, it->second, n, it->first);
  dfs(1, 1, n);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  printf("\n");
  return 0;
}
