#include <bits/stdc++.h>
using namespace std;
inline void open(const char *s) {}
inline int rd() {
  static int x, f;
  x = 0;
  f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return f > 0 ? x : -x;
}
const int N = 300010;
int m, rt;
long long ans = 0;
int ql[N], qr[N], tt = 0;
pair<int, int> a[N];
map<pair<int, int>, int> mp;
namespace UFS {
int fa[N << 1], siz[N << 1][2], st[N], top = 0;
inline int find(int x) {
  while (x ^ fa[x]) x = fa[x];
  return x;
}
inline long long link(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  long long res = 1ll * siz[x][0] * siz[x][1] + 1ll * siz[y][0] * siz[y][1];
  if (siz[x][0] + siz[x][1] > siz[y][0] + siz[y][1]) swap(x, y);
  fa[st[++top] = x] = y;
  siz[y][0] += siz[x][0];
  siz[y][1] += siz[x][1];
  return 1ll * siz[y][0] * siz[y][1] - res;
}
inline long long del(int tt) {
  long long res = 0;
  while (tt--) {
    int x = st[top--], y = fa[x];
    res -= 1ll * siz[y][0] * siz[y][1];
    siz[y][0] -= siz[x][0];
    siz[y][1] -= siz[x][1];
    fa[x] = x;
    res += 1ll * siz[y][0] * siz[y][1];
    res += 1ll * siz[x][0] * siz[x][1];
  }
  return res;
}
}  // namespace UFS
namespace Seg {
struct tree {
  int ls, rs;
  vector<pair<int, int> > vec;
  tree() {
    ls = rs = 0;
    vec.clear();
  }
} tr[N << 1];
int cnt = 0;
void build(int &o, int l, int r) {
  o = ++cnt;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(tr[o].ls, l, mid);
  build(tr[o].rs, mid + 1, r);
}
void insert(int o, int l, int r, int L, int R, pair<int, int> d) {
  if (l == L && r == R) return tr[o].vec.push_back(d), void();
  int mid = (l + r) >> 1;
  if (L <= mid) insert(tr[o].ls, l, mid, L, min(mid, R), d);
  if (R > mid) insert(tr[o].rs, mid + 1, r, max(mid + 1, L), R, d);
}
void solve(int o, int l, int r) {
  int tt = 0;
  for (auto hh : tr[o].vec) {
    long long x = UFS::link(hh.first, hh.second);
    if (x) ans += x, ++tt;
  }
  if (l != r) {
    int mid = (l + r) >> 1;
    solve(tr[o].ls, l, mid);
    solve(tr[o].rs, mid + 1, r);
  } else
    printf("%lld ", ans);
  ans += UFS::del(tt);
}
}  // namespace Seg
int main() {
  open("hh");
  m = rd();
  for (int i = 1; i <= 300000; i++) UFS::fa[i] = i, UFS::siz[i][0] = 1;
  for (int i = 300001; i <= 600000; i++) UFS::fa[i] = i, UFS::siz[i][1] = 1;
  for (int i = 1; i <= m; i++) {
    int x = rd(), y = rd();
    y += 300000;
    if (mp.count(pair<int, int>(x, y))) {
      qr[mp[pair<int, int>(x, y)]] = i - 1;
      mp.erase(pair<int, int>(x, y));
    } else
      ql[mp[pair<int, int>(x, y)] = ++tt] = i, a[tt] = pair<int, int>(x, y);
  }
  Seg::build(rt, 1, m);
  for (int i = 1; i <= tt; i++)
    if (!qr[i]) qr[i] = m;
  for (int i = 1; i <= tt; i++) Seg::insert(rt, 1, m, ql[i], qr[i], a[i]);
  Seg::solve(rt, 1, m);
  return 0;
}
