#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
map<pair<int, int>, int> mp;
struct point {
  int first, second;
  int l, r;
  point() {}
  point(int first, int second, int l, int r)
      : first(first), second(second), l(l), r(r) {}
};
long long ans[N << 1];
long long sum;
int cnt;
int cx[N << 1], cy[N << 1];
int pre[N << 1];
int sz[N << 1];
int find(int first) {
  if (!pre[first]) return first;
  return find(pre[first]);
}
struct store {
  int first;
  int cx, cy;
  int sz;
  int pre;
  store() {}
  store(int first, int cx, int cy, int sz, int pre)
      : first(first), cx(cx), cy(cy), sz(sz), pre(pre) {}
};
stack<store> stk;
void recovery(store a) {
  sz[a.first] = a.sz;
  cx[a.first] = a.cx;
  cy[a.first] = a.cy;
  pre[a.first] = a.pre;
  sum += 1LL * a.cx * a.cy;
}
void unions(int first, int second) {
  first = find(first);
  second = find(second);
  if (first == second) return;
  if (sz[first] > sz[second]) swap(first, second);
  cnt += 2;
  stk.push(store(first, cx[first], cy[first], sz[first], pre[first]));
  stk.push(store(second, cx[second], cy[second], sz[second], pre[second]));
  sum -= 1LL * cx[first] * cy[first];
  sum -= 1LL * cx[second] * cy[second];
  sz[second] += sz[first];
  cx[second] += cx[first];
  cy[second] += cy[first];
  sz[second] += sz[first];
  pre[first] = second;
  sum += 1LL * cx[second] * cy[second];
}
void rollback() {
  cnt -= 2;
  store second = stk.top();
  stk.pop();
  store first = stk.top();
  stk.pop();
  sum -= 1LL * cx[second.first] * cy[second.first];
  recovery(second);
  recovery(first);
}
void solve(int l, int r, vector<point> &v) {
  if (l == r) {
    int tmp = cnt;
    for (int i = 0; i < v.size(); i++) {
      int first = v[i].first, second = v[i].second;
      unions(first, second);
    }
    ans[l] = sum;
    while (cnt > tmp) rollback();
    return;
  }
  int tmp = cnt;
  vector<point> vl, vr;
  int mid = (l + r) >> 1;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].l == l && v[i].r == r) {
      int first = v[i].first, second = v[i].second;
      unions(first, second);
    } else if (v[i].r <= mid)
      vl.push_back(v[i]);
    else if (v[i].l > mid)
      vr.push_back(v[i]);
    else {
      vl.push_back(point(v[i].first, v[i].second, v[i].l, mid));
      vr.push_back(point(v[i].first, v[i].second, mid + 1, v[i].r));
    }
  }
  solve(l, mid, vl);
  solve(mid + 1, r, vr);
  while (cnt > tmp) {
    rollback();
  }
}
int main() {
  ios::sync_with_stdio(false);
  vector<point> v;
  int n;
  cin >> n;
  for (int i = 1; i <= 300000; i++) {
    cx[i] = 1;
    cy[i + 300000] = 1;
  }
  for (int i = 1; i <= 600000; i++) sz[i] = 1;
  for (int i = 1; i <= n; i++) {
    int first, second;
    cin >> first >> second;
    second += 300000;
    if (mp.count(make_pair(first, second))) {
      int st = mp[make_pair(first, second)];
      int ed = i - 1;
      v.push_back(point(first, second, st, ed));
      mp.erase(make_pair(first, second));
    } else {
      mp[make_pair(first, second)] = i;
    }
  }
  for (map<pair<int, int>, int>::iterator it = mp.begin(); it != mp.end();
       it++) {
    int first = it->first.first;
    int second = it->first.second;
    int st = it->second;
    int ed = n;
    v.push_back(point(first, second, st, ed));
  }
  solve(1, n, v);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
