#include <bits/stdc++.h>
using namespace std;
struct node {
  long long sum;
  long long c[2];
  struct node *l;
  struct node *r;
};
struct node *GetNode(void) {
  struct node *ret;
  ret = new struct node;
  ret->sum = 0;
  ret->c[0] = ret->c[1] = 0;
  ret->l = NULL;
  ret->r = NULL;
  return ret;
};
void Check(struct node *cur) {
  if (cur->l == NULL) cur->l = GetNode();
  if (cur->r == NULL) cur->r = GetNode();
  return;
}
void Merge(struct node *cur) {
  cur->sum = 0;
  cur->c[0] = cur->c[1] = 0;
  if (cur->l != NULL)
    cur->sum += cur->l->sum, cur->c[0] += cur->l->c[0],
        cur->c[1] += cur->l->c[1];
  if (cur->r != NULL)
    cur->sum += cur->r->sum, cur->c[0] += cur->r->c[0],
        cur->c[1] += cur->r->c[1];
}
long long Func2(long long k) { return 1 << (long long)ceil(log2(k)); }
const long long MAX = Func2(1e9);
struct node *root = GetNode();
void Edit(long long loc, long long val, long long type, struct node *cur = root,
          long long l = 1, long long r = MAX) {
  if (r < l || r < loc || loc < l)
    return;
  else if (l == r) {
    if (l == loc) cur->sum += val * loc, cur->c[type] += val;
    return;
  }
  Check(cur);
  long long mid = (l + r) / 2;
  Edit(loc, val, type, cur->l, l, mid);
  Edit(loc, val, type, cur->r, mid + 1, r);
  Merge(cur);
}
long long Get(long long a, long long b, struct node *cur = root,
              long long l = 1, long long r = MAX) {
  if (r < l || b < l || r < a) return 0;
  if (cur == NULL) return 0;
  if (a <= l && r <= b) return cur->sum;
  long long mid = (l + r) / 2;
  long long x = Get(a, b, cur->l, l, mid);
  long long y = Get(a, b, cur->r, mid + 1, r);
  return x + y;
}
pair<long long, long long> Type(long long a, long long b,
                                struct node *cur = root, long long l = 1,
                                long long r = MAX) {
  if (r < l || b < l || r < a) return {0, 0};
  if (cur == NULL) return {0, 0};
  if (a <= l && r <= b) return {cur->c[0], cur->c[1]};
  long long mid = (l + r) / 2;
  pair<long long, long long> x = Type(a, b, cur->l, l, mid);
  pair<long long, long long> y = Type(a, b, cur->r, mid + 1, r);
  return {x.first + y.first, x.second + y.second};
}
long long BinarySearch(long long cnt, long long l = 1, long long r = MAX) {
  long long mid = (l + r) / 2;
  pair<long long, long long> c = Type(mid, mid);
  pair<long long, long long> p = Type(mid + 1, MAX);
  if (p.first + p.second >= cnt) return BinarySearch(cnt, mid + 1, r);
  if (p.first + p.second + c.first + c.second < cnt)
    return BinarySearch(cnt, l, mid - 1);
  return mid;
}
long long cnt[2] = {0, 0};
int main() {
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    cnt[a] += b / abs(b);
    Edit(abs(b), b / abs(b), a);
    if (cnt[1]) {
      long long loc = BinarySearch(cnt[1]);
      if (Type(loc, MAX).first == 0) {
        ans -= loc;
        if (cnt[0]) loc = BinarySearch(cnt[1] + 1);
      }
      ans += Get(loc, MAX);
    }
    ans += root->sum;
    cout << ans << endl;
  }
  return 0;
}
