#include <bits/stdc++.h>
using namespace std;
struct treap {
  int x, y, cnt;
  long long sum;
  treap *l, *r;
};
long long getsum(treap *t) { return t ? t->sum : 0; }
int getcnt(treap *t) { return t ? t->cnt : 0; }
void recalc(treap *t) {
  if (t) {
    t->sum = t->x + getsum(t->l) + getsum(t->r);
    t->cnt = 1 + getcnt(t->l) + getcnt(t->r);
  }
}
void split(treap *t, int k, treap *&tl, treap *&tr) {
  if (!t)
    tl = tr = NULL;
  else if (k < t->x) {
    split(t->l, k, tl, t->l);
    tr = t;
  } else {
    split(t->r, k, t->r, tr);
    tl = t;
  }
  recalc(tl);
  recalc(tr);
}
void merge(treap *&t, treap *tl, treap *tr) {
  if (!tl || !tr)
    t = tl ? tl : tr;
  else if (tl->y < tr->y) {
    merge(tr->l, tl, tr->l);
    t = tr;
  } else {
    merge(tl->r, tl->r, tr);
    t = tl;
  }
  recalc(t);
}
long long update(treap *&t, int x) {
  treap *tl, *tr;
  split(t, x, tl, tr);
  t = new treap{x, rand(), 1, x, NULL, NULL};
  long long res = getsum(tl) + ((long long)x * getcnt(tr));
  merge(t, tl, t);
  merge(t, t, tr);
  return res;
}
const int N = 4e5 + 2;
struct UnionFind {
  int p[N], mina[N];
  set<pair<int, int> > st[N];
  long long cost[N];
  treap *t[N];
  UnionFind() {
    for (int i = 0; i < N; i++) {
      p[i] = i;
      mina[i] = N;
    }
  }
  int get(int v) { return p[v] = (v == p[v] ? v : get(p[v])); }
  long long add(int ai, long long bi) {
    int v = get(ai);
    st[v].insert({ai, bi});
    long long res = 0;
    if (ai < mina[v])
      res -= getsum(t[v]) * (mina[v] - ai);
    else
      res -= bi * (ai - mina[v]);
    mina[v] = min(mina[v], ai);
    res += update(t[v], bi);
    cost[v] += res;
    return res;
  }
  long long unite(int v, int u) {
    v = get(v), u = get(u);
    if (v == u) return 0;
    if (st[v].size() < st[u].size()) swap(v, u);
    p[u] = v;
    long long res = -cost[u];
    while (!st[u].empty()) {
      auto x = v < u ? *st[u].begin() : *st[u].rbegin();
      st[u].erase(x);
      res += add(x.first, x.second);
    }
    return res;
  }
  long long merge(int v, int u) {
    u = get(u);
    if (!st[u].empty()) return unite(v, u);
    return 0;
  }
};
UnionFind uf;
long long f(int a, int b) {
  long long res = uf.add(a, b);
  int v = uf.get(a), minv = uf.mina[v];
  res += uf.unite(v, minv + uf.st[v].size() - 1);
  res += uf.merge(v, minv + uf.st[v].size());
  res += uf.merge(v, minv - 1);
  return res;
}
void solve() {
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    res += f(a, b);
    cout << res << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}
