#include <bits/stdc++.h>
using namespace std;
long long Q, tt, ans, fa[300100 << 1], sz[300100 << 1];
pair<long long, long long> cnt[300100 << 1];
struct Node {
  long long ls, rs;
  vector<pair<long long, long long> > dn;
} node[300100 << 1];
map<pair<long long, long long>, long long> pos;
map<pair<long long, long long>, long long>::iterator it;
vector<pair<long long, long long> > gg;
long long ff(long long u) { return u == fa[u] ? u : ff(fa[u]); }
inline long long calc(long long u) { return cnt[u].first * cnt[u].second; }
pair<long long, long long> operator+(const pair<long long, long long> &u,
                                     const pair<long long, long long> &v) {
  return make_pair(u.first + v.first, u.second + v.second);
}
pair<long long, long long> operator-(const pair<long long, long long> &u,
                                     const pair<long long, long long> &v) {
  return make_pair(u.first - v.first, u.second - v.second);
}
void build(long long now, long long l, long long r) {
  if (l == r) return;
  long long mid = ((l + r) >> 1);
  node[now].ls = ++tt;
  build(tt, l, mid);
  node[now].rs = ++tt;
  build(tt, mid + 1, r);
}
void add(long long now, long long l, long long r, long long u, long long v,
         pair<long long, long long> w) {
  if (u <= l && r <= v) {
    node[now].dn.push_back(w);
    return;
  }
  long long mid = ((l + r) >> 1);
  if (u <= mid) add(node[now].ls, l, mid, u, v, w);
  if (mid < v) add(node[now].rs, mid + 1, r, u, v, w);
}
void dfs(long long now, long long l, long long r) {
  long long i, j, p, q, st = gg.size();
  for (i = 0; i < node[now].dn.size(); i++) {
    p = node[now].dn[i].first;
    q = node[now].dn[i].second;
    p = ff(p), q = ff(q);
    if (p == q) continue;
    if (sz[p] < sz[q]) swap(p, q);
    ans -= calc(p) + calc(q);
    sz[p] += sz[q];
    cnt[p] = cnt[p] + cnt[q];
    fa[q] = p;
    gg.push_back(make_pair(p, q));
    ans += calc(p);
  }
  if (l == r)
    printf("%lld ", ans);
  else {
    long long mid = ((l + r) >> 1);
    dfs(node[now].ls, l, mid);
    dfs(node[now].rs, mid + 1, r);
  }
  for (; gg.size() > st; gg.pop_back()) {
    p = gg.back().first;
    q = gg.back().second;
    ans -= calc(p);
    sz[p] -= sz[q];
    cnt[p] = cnt[p] - cnt[q];
    fa[q] = q;
    ans += calc(p) + calc(q);
  }
}
int main() {
  long long i, j;
  for (i = 1; i <= 300000; i++) fa[i] = i, cnt[i] = make_pair(1, 0), sz[i] = 1;
  for (i = 300000 + 1; i <= 300000 * 2; i++)
    fa[i] = i, cnt[i] = make_pair(0, 1), sz[i] = 1;
  cin >> Q;
  build(tt = 1, 1, Q);
  for (i = 1; i <= Q; i++) {
    pair<long long, long long> tmp;
    scanf("%lld%lld", &tmp.first, &tmp.second);
    tmp.second += 300000;
    if (pos.count(tmp))
      add(1, 1, Q, pos[tmp], i - 1, tmp), pos.erase(tmp);
    else
      pos[tmp] = i;
  }
  for (it = pos.begin(); it != pos.end(); it++)
    add(1, 1, Q, (*it).second, Q, (*it).first);
  dfs(1, 1, Q);
}
