#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 10;
struct P1 {
  int x, fx, y, rky;
};
struct P {
  int x, y;
  bool operator<(P B) const {
    if (x != B.x) return x < B.x;
    return y < B.y;
  }
};
vector<P> v[N << 2];
map<P, int> mp;
long long ans[N], now = 0, szx[N], szy[N], rk[N], f[N];
int rt(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
void merg(int x, int y, stack<P1>& st) {
  x = rt(x);
  y = rt(y);
  if (x == y) return;
  if (rk[x] > rk[y]) swap(x, y);
  P1 t;
  t.x = x;
  t.fx = f[x];
  t.y = y;
  t.rky = rk[y];
  f[x] = y;
  if (rk[x] == rk[y]) rk[y]++;
  now -= szx[y] * szy[y];
  now -= szx[x] * szy[x];
  szx[y] += szx[x];
  szy[y] += szy[x];
  now += szx[y] * szy[y];
  st.push(t);
}
void del(stack<P1>& s) {
  while (!s.empty()) {
    P1 t = s.top();
    s.pop();
    int x = t.x, y = t.y;
    f[t.x] = t.fx;
    rk[t.y] = t.rky;
    now -= szx[y] * szy[y];
    szx[t.y] -= szx[t.x];
    szy[t.y] -= szy[t.x];
    now += szx[x] * szy[x] + szx[y] * szy[y];
  }
}
void up(int x, int l, int r, int L, int R, P z) {
  if (l >= L && r <= R) {
    v[x].push_back(z);
    return;
  }
  if (L <= (l + r) / 2) up(x << 1, l, (l + r) / 2, L, R, z);
  if (R > (l + r) / 2) up(x << 1 | 1, (l + r) / 2 + 1, r, L, R, z);
}
void dfs(int x, int l, int r) {
  stack<P1> s;
  for (P t : v[x]) {
    merg(t.x, t.y, s);
  }
  if (l == r)
    ans[l] = now;
  else {
    dfs(x << 1, l, (l + r) / 2);
    dfs(x << 1 | 1, (l + r) / 2 + 1, r);
  }
  del(s);
}
int main() {
  int n;
  P t;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &t.x, &t.y);
    t.y += 3e5;
    if (mp[t]) {
      up(1, 1, n, mp[t], i - 1, t);
      mp[t] = 0;
    } else
      mp[t] = i;
  }
  for (int i = 1; i <= 6e5; i++) {
    rk[i] = 1;
    f[i] = i;
    if (i <= 3e5)
      szx[i] = 1;
    else
      szy[i] = 1;
  }
  for (auto x : mp) {
    if (x.second) up(1, 1, n, x.second, n, x.first);
  }
  dfs(1, 1, n);
  for (int i = 1; i <= n; i++) {
    if (i != 1) printf(" ");
    printf("%lld", ans[i]);
  }
  return 0;
}
