#include <bits/stdc++.h>
const int N = 200005, LN = 30;
int n, root[N], f[N], size[N];
long long sum[N];
int lc[N * LN], rc[N * LN], num[N * LN], idx;
long long sum0[N * LN], sum1[N * LN], ans;
void pushup(int root) {
  num[root] = num[lc[root]] + num[rc[root]];
  sum0[root] = sum0[lc[root]] + sum0[rc[root]];
  sum1[root] = sum1[lc[root]] + sum1[rc[root]] + sum0[lc[root]] * num[rc[root]];
}
void insert(int &root, int pos, int l = 1, int r = n) {
  if (!root) root = ++idx;
  if (l == r) {
    num[root] = 1, sum0[root] = pos;
    return;
  }
  int mid = l + r >> 1;
  if (pos <= mid)
    insert(lc[root], pos, l, mid);
  else
    insert(rc[root], pos, mid + 1, r);
  pushup(root);
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  lc[x] = merge(lc[x], lc[y]);
  rc[x] = merge(rc[x], rc[y]);
  return pushup(x), x;
}
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void _union(int a, int b) {
  ans -= (long long)sum[b] * (b - a);
  ans -= sum1[root[a]] + sum1[root[b]];
  root[a] = merge(root[a], root[b]), root[b] = 0;
  ans += sum1[root[a]];
  f[b] = a, sum[a] += sum[b], size[a] += size[b];
}
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n;
  for (int i = 1; i < N; ++i) f[i] = i;
  for (int i = 1; i <= n; ++i) {
    int a, b, g;
    std::cin >> a >> b, g = find(a);
    ans -= (long long)b * (a - g), ++size[g], sum[g] += b;
    ans -= sum1[root[g]];
    insert(root[g], b);
    ans += sum1[root[g]];
    if (g + size[g] < N && f[g + size[g]] == g + size[g])
      _union(g, g + size[g]);
    std::cout << ans << '\n';
  }
  return 0;
}
