#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
const int Base = 300000;
vector<pair<int, int> > tr[maxn * 4];
map<pair<int, int>, int> mp;
map<pair<int, int>, int>::iterator it;
long long res[maxn], cnt_x[maxn * 2], cnt_y[maxn * 2], sz[maxn * 2];
int f[maxn * 2];
long long ans;
pair<int, int> a[maxn];
int get(int x) {
  if (x == f[x]) return x;
  return get(f[x]);
}
void add(int o, int l, int r, int ql, int qr, pair<int, int> val) {
  if (l >= ql && r <= qr) {
    tr[o].push_back(val);
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) add((o << 1), l, mid, ql, qr, val);
  if (qr > mid) add((o << 1 | 1), mid + 1, r, ql, qr, val);
}
void del(int x, int y) {
  int x1 = get(x), y1 = get(y);
  if (x1 != y1) return;
  ans -= cnt_x[x] * cnt_y[x];
  cnt_x[x] -= cnt_x[y], cnt_y[x] -= cnt_y[y];
  sz[x] -= sz[y];
  ans += cnt_x[x] * cnt_y[x];
  ans += cnt_x[y] * cnt_y[y];
  f[y] = y;
}
pair<int, int> merge(int x, int y) {
  int x1 = get(x), y1 = get(y);
  if (x1 == y1) return make_pair(-1, -1);
  if (sz[x1] < sz[y1]) swap(x1, y1);
  ans -= cnt_x[x1] * cnt_y[x1];
  ans -= cnt_x[y1] * cnt_y[y1];
  sz[x1] += sz[y1];
  cnt_x[x1] += cnt_x[y1], cnt_y[x1] += cnt_y[y1];
  ans += cnt_x[x1] * cnt_y[x1];
  f[y1] = x1;
  return make_pair(x1, y1);
}
void dfs(int o, int l, int r) {
  if (l == 12) {
    l++;
    l--;
  }
  stack<pair<int, int> > s;
  for (auto x : tr[o]) {
    pair<int, int> tmp = merge(x.first, x.second);
    if (tmp.first != -1) s.push(tmp);
  }
  if (l == r)
    res[l] = ans;
  else {
    int mid = (l + r) >> 1;
    dfs((o << 1), l, mid);
    dfs((o << 1 | 1), mid + 1, r);
  }
  while (!s.empty()) {
    del(s.top().first, s.top().second);
    s.pop();
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    y += Base;
    a[i] = make_pair(x, y);
    if (mp.find(a[i]) == mp.end())
      mp[a[i]] = i;
    else {
      add(1, 1, n, mp[a[i]], i - 1, a[i]);
      mp.erase(a[i]);
    }
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    add(1, 1, n, it->second, n, it->first);
  }
  for (int i = 1; i <= Base; i++) {
    f[i] = i, cnt_x[i] = 1, cnt_y[i] = 0, sz[i] = 1;
  }
  for (int i = Base + 1; i <= Base * 2; i++) {
    f[i] = i, cnt_x[i] = 0, cnt_y[i] = 1, sz[i] = 1;
  }
  dfs(1, 1, n);
  for (int i = 1; i <= n; i++) printf("%lld ", res[i]);
}
