#include <bits/stdc++.h>
using namespace std;
namespace DsuBackup {
vector<pair<long long *, long long>> backups;
long long n;
long long ans = 0;
vector<long long> p;
vector<long long> rank;
vector<long long> cnt_f;
vector<long long> cnt_s;
void init(long long n_) {
  n = n_;
  p.resize(2 * n);
  rank.resize(2 * n);
  cnt_f.resize(2 * n);
  cnt_s.resize(2 * n);
  for (long long i = 0; i < 2 * n; i++) {
    p[i] = i;
    if (i < n) {
      cnt_f[i] = 1;
    } else {
      cnt_s[i] = 1;
    }
  }
}
long long get(long long v) {
  if (p[v] != v) {
    return get(p[v]);
  } else {
    return v;
  }
}
void merge(long long a, long long b) {
  a = get(a);
  b = get(b);
  if (a != b) {
    if (rank[a] < rank[b]) {
      swap(a, b);
    }
    backups.emplace_back(&p[b], p[b]);
    p[b] = a;
    long long new_ans = ans;
    new_ans -= cnt_f[a] * cnt_s[a];
    new_ans -= cnt_f[b] * cnt_s[b];
    backups.emplace_back(&cnt_f[a], cnt_f[a]);
    cnt_f[a] += cnt_f[b];
    backups.emplace_back(&cnt_s[a], cnt_s[a]);
    cnt_s[a] += cnt_s[b];
    backups.emplace_back(&cnt_f[b], cnt_f[b]);
    cnt_f[b] = 0;
    backups.emplace_back(&cnt_s[b], cnt_s[b]);
    cnt_s[b] = 0;
    new_ans += cnt_f[a] * cnt_s[a];
    backups.emplace_back(&ans, ans);
    ans = new_ans;
    if (rank[a] == rank[a]) {
      backups.emplace_back(&rank[a], rank[a]);
      rank[a]++;
    }
  }
}
void backup(long long to) {
  while ((long long)backups.size() > to) {
    *backups.back().first = backups.back().second;
    backups.pop_back();
  }
}
}  // namespace DsuBackup
namespace DcpOffline {
long long n;
vector<long long> answers;
vector<vector<pair<long long, long long>>> t;
void add_edge(long long v, long long l, long long r, long long ql, long long qr,
              pair<long long, long long> val) {
  if (r <= ql || qr <= l) {
    return;
  } else if (ql <= l && r <= qr) {
    t[v].push_back(val);
  } else {
    long long m = (r + l) >> 1;
    add_edge(2 * v + 1, l, m, ql, qr, val);
    add_edge(2 * v + 2, m, r, ql, qr, val);
  }
}
void add_edge(pair<long long, long long> ed, long long l, long long r) {
  add_edge(0, 0, n, l, r, ed);
}
void go_down(long long v, long long l, long long r) {
  long long was_backups = (long long)DsuBackup::backups.size();
  for (auto x : t[v]) {
    DsuBackup::merge(x.first, x.second);
  }
  if (l + 1 == r) {
    answers[l] = DsuBackup::ans;
  } else {
    long long m = (r + l) >> 1;
    go_down(2 * v + 1, l, m);
    go_down(2 * v + 2, m, r);
  }
  DsuBackup::backup(was_backups);
}
void run() {
  DsuBackup::init(n);
  go_down(0, 0, n);
}
void init(long long n_) {
  n = n_;
  answers.resize(n);
  t.resize(4 * n);
}
}  // namespace DcpOffline
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  const long long MAXN = 5e5 + 239;
  long long q;
  cin >> q;
  DcpOffline::init(MAXN);
  set<pair<long long, long long>> seen;
  map<pair<long long, long long>, long long> wh;
  for (long long i = 0; i < q; i++) {
    long long x, y;
    cin >> x >> y;
    y += MAXN;
    if (seen.count({x, y})) {
      DcpOffline::add_edge({x, y}, wh[{x, y}], i);
      seen.erase({x, y});
    } else {
      seen.insert({x, y});
    }
    wh[{x, y}] = i;
  }
  for (auto t : seen) {
    DcpOffline::add_edge({t.first, t.second}, wh[{t.first, t.second}], q);
  }
  DcpOffline::run();
  for (long long i = 0; i < q; i++) {
    cout << DcpOffline::answers[i] << ' ';
  }
}
