#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool chkmin(T1 &x, T2 y) {
  return y < x ? (x = y, true) : false;
}
template <typename T1, typename T2>
bool chkmax(T1 &x, T2 y) {
  return y > x ? (x = y, true) : false;
}
const int N = 300005;
vector<pair<int, int>> h[4 * N];
namespace dsu {
vector<pair<long long &, long long>> ops;
vector<char> added;
long long cnt[N + N][2];
long long q[N + N];
long long ans;
int ge(int x) { return q[x] == x ? x : ge(q[x]); }
void un(int x, int y) {
  x = ge(x), y = ge(y);
  added.push_back(x != y ? 1 : 0);
  if (x == y) return;
  if (cnt[x][0] + cnt[x][1] > cnt[y][0] + cnt[y][1]) swap(x, y);
  ops.push_back({ans, ans});
  ans += cnt[x][0] * cnt[y][1] + cnt[x][1] * cnt[y][0];
  for (int j = 0; j < 2; ++j) {
    ops.push_back({cnt[y][j], cnt[y][j]});
    cnt[y][j] += cnt[x][j];
  }
  ops.push_back({q[x], q[x]});
  q[x] = y;
}
void backtrack() {
  if (!added.back()) {
    added.pop_back();
    return;
  }
  added.pop_back();
  for (int i = 0; i < 4; ++i) {
    ops.back().first = ops.back().second;
    ops.pop_back();
  }
}
}  // namespace dsu
vector<pair<int, int>> t[4 * N];
void add(int v, int vl, int vr, int l, int r, pair<int, int> p) {
  if (l > r || vr < l || r < vl) return;
  if (l <= vl && vr <= r) {
    t[v].push_back(p);
    return;
  }
  int vm = (vl + vr) >> 1;
  add(v + v, vl, vm, l, r, p);
  add(v + v + 1, vm + 1, vr, l, r, p);
}
void dfs(int v, int vl, int vr) {
  for (auto &p : t[v]) dsu::un(p.first, p.second);
  if (vl == vr)
    cout << dsu::ans << ' ';
  else {
    int vm = (vl + vr) >> 1;
    dfs(v + v, vl, vm);
    dfs(v + v + 1, vm + 1, vr);
  }
  for (int i = 0; i < t[v].size(); ++i) dsu::backtrack();
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < N + N; ++i) {
    dsu::cnt[i][i >= N] = 1;
    dsu::q[i] = i;
  }
  int Q;
  cin >> Q;
  map<pair<int, int>, vector<int>> ev;
  for (int t = 1; t <= Q; ++t) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    y += N;
    ev[{x, y}].push_back(t);
  }
  for (auto &p : ev) {
    auto &e = p.second;
    for (int i = 0; i < e.size(); i += 2) {
      int l = e[i];
      int r = Q;
      if (i + 1 < e.size()) r = e[i + 1] - 1;
      add(1, 1, Q, l, r, p.first);
    }
  }
  dfs(1, 1, Q);
  cout << '\n';
  return 0;
}
