#include <bits/stdc++.h>
using namespace std;
const int maxn = 300007;
vector<pair<int, int> > sgt[maxn << 2];
void update(int id, int l, int r, int L, int R, pair<int, int> p) {
  if (l >= L && r <= R) {
    sgt[id].push_back(p);
    return;
  }
  if (l > R || L > r) return;
  int mid = (l + r) / 2;
  update((id << 1), l, mid, L, R, p);
  update(((id << 1) | 1), mid + 1, r, L, R, p);
}
long long ans[maxn], res;
int siz[maxn << 1][2], fa[maxn << 1];
int fnd(int x) { return fa[x] == x ? x : fnd(fa[x]); }
stack<int> o;
void merge(int x, int y) {
  x = fnd(x), y = fnd(y);
  if (x == y) return;
  if (siz[x][0] + siz[x][1] < siz[y][0] + siz[y][1]) swap(x, y);
  res -= 1ll * siz[x][0] * siz[x][1];
  res -= 1ll * siz[y][0] * siz[y][1];
  siz[x][0] += siz[y][0];
  siz[x][1] += siz[y][1];
  res += 1ll * siz[x][0] * siz[x][1];
  fa[y] = x;
  o.push(y);
}
void clear(stack<int> cur) {
  while (!cur.empty()) {
    int y = cur.top();
    cur.pop();
    int x = fa[y];
    res -= 1ll * siz[x][0] * siz[x][1];
    siz[x][0] -= siz[y][0];
    siz[x][1] -= siz[y][1];
    fa[y] = y;
    res += 1ll * siz[x][0] * siz[x][1];
    res += 1ll * siz[y][0] * siz[y][1];
  }
}
void query(int id, int l, int r) {
  while (!o.empty()) o.pop();
  for (int i = 0; i < sgt[id].size(); ++i)
    merge(sgt[id][i].first, sgt[id][i].second + maxn);
  stack<int> cur = o;
  if (l == r)
    ans[l] = res;
  else {
    int mid = (l + r) / 2;
    query((id << 1), l, mid);
    query(((id << 1) | 1), mid + 1, r);
  }
  clear(cur);
}
int n;
pair<int, int> a[maxn];
map<pair<int, int>, int> last;
int main() {
  for (int i = 1; i < maxn; ++i) {
    siz[i][0] = 1;
    siz[i + maxn][1] = 1;
    fa[i] = i;
    fa[i + maxn] = i + maxn;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    if (last.find(a[i]) != last.end() && last[a[i]] != -1) {
      update(1, 1, n, last[a[i]], i - 1, a[i]);
      last[a[i]] = -1;
    } else {
      last[a[i]] = i;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (last[a[i]] == i) {
      update(1, 1, n, last[a[i]], n, a[i]);
    }
  query(1, 1, n);
  for (int i = 1; i <= n; ++i) printf("%I64d ", ans[i]);
  puts("");
  return 0;
}
