#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int rd() {
  int k = 0;
  char c = getchar();
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') k = k * 10 + c - '0', c = getchar();
  return k;
}
const int N = 300000, M = 600001;
int T, x, y, f[M], sx[M], sy[M];
long long ans;
vector<pair<int, int> > v[M << 1];
map<pair<int, int>, int> mp;
pair<int, int> p;
int F(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
void Add(int x, int l, int r, int s, int t, pair<int, int> p) {
  if (s <= l && r <= t) {
    v[x].push_back(p);
    return;
  }
  if (s <= ((l + r) >> 1)) Add((x << 1), l, ((l + r) >> 1), s, t, p);
  if (((l + r) >> 1) < t) Add((x << 1 | 1), ((l + r) >> 1) + 1, r, s, t, p);
}
void Solve(int x, int l, int r) {
  long long pre = ans;
  stack<int> S;
  for (int i = 0; i < v[x].size(); ++i) {
    int a = F(v[x][i].first), b = F(v[x][i].second + N);
    if (a == b) continue;
    if (sx[a] + sy[a] > sx[b] + sy[b]) {
      int t = a;
      a = b, b = t;
    }
    ans -= (long long)sx[a] * sy[a] + (long long)sx[b] * sy[b],
        f[a] = b, sx[b] += sx[a], sy[b] += sy[a];
    ans += (long long)sx[b] * sy[b], S.push(a);
  }
  if (l == r)
    printf("%lld ", ans);
  else
    Solve((x << 1), l, ((l + r) >> 1)),
        Solve((x << 1 | 1), ((l + r) >> 1) + 1, r);
  while (!S.empty()) {
    int t = S.top(), z = f[t];
    S.pop(), f[t] = t, sx[z] -= sx[t], sy[z] -= sy[t];
  }
  ans = pre;
}
int main() {
  T = rd();
  for (int i = 1; i <= T; ++i) {
    x = rd(), y = rd(), p = make_pair(x, y);
    if (mp.count(p))
      Add(1, 1, T, mp[p], i - 1, p), mp.erase(p);
    else
      mp[p] = i;
  }
  for (auto t : mp) Add(1, 1, T, t.second, T, t.first);
  for (int i = 1; i <= N; ++i) sx[f[i] = i] = 1;
  for (int i = N + 1; i < M; ++i) sy[f[i] = i] = 1;
  Solve(1, 1, T);
  return 0;
}
