#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
inline long long add(long long v1, long long v2) {
  v1 += v2;
  if (v1 >= mod) v1 -= mod;
  if (v1 < 0) v1 += mod;
  return v1;
}
inline long long mul(long long v1, long long v2) { return v1 * v2 % mod; }
inline long long mypow(long long v, long long t) {
  long long res = 1;
  while (t) {
    if (t & 1) res = res * v % mod;
    v = v * v % mod;
    t >>= 1;
  }
  return res;
}
inline void bye() {
  puts("");
  exit(0);
}
const int N = 202020;
const int MEM = 360004;
struct Treap {
  static Treap mem[MEM], *pmem;
  Treap *l, *r;
  int val;
  long long sum;
  int size;
  int pri;
  Treap() : l(NULL), r(NULL), size(0) {}
  Treap(int _val)
      : l(NULL), r(NULL), val(_val), sum(_val), size(1), pri(rand()) {}
} Treap::mem[MEM], *Treap::pmem = Treap::mem;
int size(const Treap *t) { return t ? t->size : 0; }
long long sum(const Treap *t) { return t ? t->sum : 0; }
void pull(Treap *t) {
  if (!t) return;
  t->size = size(t->l) + size(t->r) + 1;
  t->sum = sum(t->l) + sum(t->r) + t->val;
}
Treap *merge(Treap *a, Treap *b) {
  if (!a || !b) return a ? a : b;
  if (a->pri > b->pri) {
    a->r = merge(a->r, b);
    pull(a);
    return a;
  } else {
    b->l = merge(a, b->l);
    pull(b);
    return b;
  }
}
void split(Treap *t, int k, Treap *&a, Treap *&b) {
  if (!t)
    a = b = NULL;
  else if (t->val >= k) {
    a = t;
    split(t->r, k, a->r, b);
    pull(a);
  } else {
    b = t;
    split(t->l, k, a, b->l);
    pull(b);
  }
}
int cntp = 0;
void split2(Treap *t, int k, Treap *&a, Treap *&b) {
  if (!t)
    a = b = NULL;
  else if (size(t->l) + 1 <= k) {
    a = t;
    split2(t->r, k - size(t->l) - 1, a->r, b);
    pull(a);
  } else {
    b = t;
    split2(t->l, k, a, b->l);
    pull(b);
  }
}
set<int> st;
Treap *ptr[N << 1];
Treap *ll, *mid, *rr, *tmp;
int main(void) {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int p, v;
    scanf("%d %d", &p, &v);
    auto it = st.upper_bound(p);
    if (it != st.begin()) {
      it--;
      int l = *it, r = *it + size(ptr[l]);
      if (l <= p && p <= r) {
        split(ptr[l], v, ll, rr);
        ans += sum(rr);
        ans += ((l + size(ll)) - p) * 1ll * v;
        ptr[r] = new (Treap::pmem++) Treap(v);
        ptr[l] = merge(ll, merge(ptr[r], rr));
      } else {
        ptr[p] = new (Treap::pmem++) Treap(v);
        st.insert(p);
      }
    } else {
      ptr[p] = new (Treap::pmem++) Treap(v);
      st.insert(p);
    }
    it = --st.upper_bound(p);
    int l = *it, r = *it + size(ptr[l]);
    if (st.find(r) != st.end()) {
      st.erase(r);
      if (size(ptr[l]) < size(ptr[r])) {
        ans += (r - l) * 1ll * sum(ptr[l]);
        ans -= (r - l) * 1ll * sum(ptr[r]);
        while (size(ptr[l])) {
          split2(ptr[l], 1, mid, rr);
          ptr[l] = rr;
          split(rr, mid->val, tmp, rr);
          int pos = r + size(tmp);
          ans -= sum(rr);
          rr = merge(tmp, rr);
          split(ptr[r], mid->val, ll, rr);
          ans += sum(rr);
          ans += ((l + size(ll)) - pos) * 1ll * mid->val;
          ptr[r] = merge(ll, merge(mid, rr));
        }
        swap(ptr[l], ptr[r]);
      } else {
        while (size(ptr[r])) {
          split2(ptr[r], 1, mid, rr);
          ptr[r] = rr;
          split(rr, mid->val, tmp, rr);
          int pos = r + size(tmp);
          ans -= sum(rr);
          rr = merge(tmp, rr);
          split(ptr[l], mid->val, ll, rr);
          ans += sum(rr);
          ans += ((l + size(ll)) - pos) * 1ll * mid->val;
          ptr[l] = merge(ll, merge(mid, rr));
        }
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
