#include <bits/stdc++.h>
using namespace std;
struct Dsu {
  int fa[600015];
  int siz[600015];
  long long cntx[600015];
  long long cnty[600015];
  long long cnt = 0;
  stack<pair<int, int> > ostack;
  void init() {
    cnt = 0;
    for (int i = 0; i < 600015; i++) fa[i] = i, siz[i] = 1;
    for (int i = 0; i < 300005; i++) cntx[i] = 1;
    for (int i = 300005 + 1; i < 600015; i++) cnty[i] = 1;
  }
  void rev_oper(int u, int v) {
    cnt -= cntx[v] * cnty[v];
    fa[u] = u;
    siz[v] -= siz[u];
    cntx[v] -= cntx[u];
    cnty[v] -= cnty[u];
    cnt += cntx[u] * cnty[u] + cntx[v] * cnty[v];
  }
  int find(int u) {
    while (fa[u] != u) u = fa[u];
    return u;
  }
  int same(int u, int v) { return find(u) == find(v); }
  int unin(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return 0;
    if (siz[u] > siz[v]) swap(u, v);
    cnt -= cntx[u] * cnty[u] + cntx[v] * cnty[v];
    fa[u] = v;
    siz[v] += siz[u];
    cntx[v] += cntx[u];
    cnty[v] += cnty[u];
    cnt += cntx[v] * cnty[v];
    ostack.push(make_pair(u, v));
    return 1;
  }
  void timeBack() {
    if (!ostack.empty()) {
      pair<int, int> p = ostack.top();
      ostack.pop();
      rev_oper(p.first, p.second);
    }
  }
};
map<pair<int, int>, int> mp;
Dsu dsu;
vector<pair<int, int> > tn[1048576];
void modify(int no, int l, int r, int lq, int rq, pair<int, int> val) {
  if (l >= lq && r <= rq) {
    tn[no].push_back(val);
    return;
  }
  if (l > rq || r < lq) return;
  int mid = (l + r) / 2;
  modify(no << 1, l, mid, lq, rq, val);
  modify((no << 1) + 1, mid + 1, r, lq, rq, val);
}
void process(int no, int l, int r) {
  int revCnt = 0;
  for (int i = 0; i < tn[no].size(); i++) {
    int u = tn[no][i].first;
    int v = tn[no][i].second;
    revCnt += dsu.unin(u, v);
  }
  if (l == r) {
    printf("%I64d ", dsu.cnt);
  } else {
    int mid = (l + r) / 2;
    process(no << 1, l, mid);
    process((no << 1) + 1, mid + 1, r);
  }
  for (int i = 0; i < revCnt; i++) {
    dsu.timeBack();
  }
}
int main() {
  int m;
  dsu.init();
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    v = v + 300005;
    pair<int, int> t = make_pair(u, v);
    if (mp[t] == 0) {
      mp[t] = i + 1;
    } else {
      modify(1, 1, m, mp[t], i, make_pair(u, v));
      mp[t] = 0;
    }
  }
  for (map<pair<int, int>, int>::iterator it = mp.begin(); it != mp.end();
       it++) {
    if (it->second == 0) continue;
    int u = it->first.first;
    int v = it->first.second;
    modify(1, 1, m, it->second, m, make_pair(u, v));
  }
  process(1, 1, m);
  return 0;
}
