#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 1;
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  if (f) x = -x;
}
template <typename T>
inline void Mx(T &x, T y) {
  x < y && (x = y);
}
template <typename T>
inline void Mn(T &x, T y) {
  x > y && (x = y);
}
map<pair<int, int>, int> mp;
const int N = 300050;
int f[N << 1], X[N << 1], Y[N << 1], n;
long long c[N << 1][2], cnt;
vector<pair<int, int> > v[N << 2];
void change(int l, int r, int p, int L, int R, pair<int, int> x) {
  if (L <= l && r <= R) return v[p].push_back(x), void();
  int mid = (l + r) >> 1;
  if (mid >= L) change(l, mid, p << 1, L, R, x);
  if (mid < R) change(mid + 1, r, p << 1 | 1, L, R, x);
}
const int lim = 300000;
int find(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
void solve(int l, int r, int p, long long ans) {
  int t = cnt;
  for (auto t : v[p]) {
    int x = find(t.first), y = find(t.second + lim);
    if (x == y) continue;
    if (c[x][0] + c[x][1] < c[y][0] + c[y][1]) swap(x, y);
    X[++cnt] = x, Y[cnt] = y;
    ans -= c[x][0] * c[x][1] + c[y][0] * c[y][1];
    f[y] = x, c[x][0] += c[y][0], c[x][1] += c[y][1];
    ans += c[x][0] * c[x][1];
  }
  if (l == r)
    printf("%lld ", ans);
  else {
    int mid = (l + r) >> 1;
    solve(l, mid, p << 1, ans), solve(mid + 1, r, p << 1 | 1, ans);
  }
  while (cnt > t) {
    int x = X[cnt], y = Y[cnt];
    c[x][0] -= c[y][0], c[x][1] -= c[y][1];
    f[y] = y, cnt--;
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    read(x), read(y);
    if (mp[make_pair(x, y)])
      change(1, n, 1, mp[make_pair(x, y)], i - 1, make_pair(x, y)),
          mp[make_pair(x, y)] = 0;
    else
      mp[make_pair(x, y)] = i;
  }
  for (auto j : mp) {
    pair<int, int> px = j.first;
    int st = j.second;
    if (!st) continue;
    change(1, n, 1, st, n, px);
  }
  for (int i = 1; i <= 600000; i++) f[i] = i, c[i][i > lim] = 1;
  solve(1, n, 1, 0);
  return 0;
}
