#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
using namespace std;
long long read() {
  char c;
  long long num, f = 1;
  while (c = getchar(), !isdigit(c))
    if (c == '-') f = -1;
  num = c - '0';
  while (c = getchar(), isdigit(c)) num = num * 10 + c - '0';
  return num * f;
}
const long long N = 1e6 + 5;
long long n, m, noden, tot, cnt, pre1, pre2;
long long ans, sum;
set<long long> S;
struct node {
  long long lc, rc, rnd, val, sz;
} a[N];
struct fhq {
  long long rt;
  void pushup(long long x) { a[x].sz = a[a[x].lc].sz + a[a[x].rc].sz + 1; }
  long long NEW(long long val) {
    a[++noden] = (node){0, 0, rand(), val, 1};
    return noden;
  }
  void split(long long now, long long val, long long &x, long long &y) {
    if (!now) {
      x = y = 0;
      return;
    }
    if (a[now].val >= val) {
      x = now;
      split(a[now].rc, val, a[now].rc, y);
    } else {
      y = now;
      split(a[now].lc, val, x, a[now].lc);
    }
    pushup(now);
  }
  long long merge(long long x, long long y) {
    if (!x || !y) return x | y;
    if (a[x].rnd < a[y].rnd) {
      a[x].rc = merge(a[x].rc, y);
      pushup(x);
      return x;
    } else {
      a[y].lc = merge(x, a[y].lc);
      pushup(y);
      return y;
    }
  }
  long long getk(long long x, long long k) {
    if (!k || k > a[rt].sz) return 0;
    for (;;) {
      if (k <= a[a[x].lc].sz)
        x = a[x].lc;
      else if (k == a[a[x].lc].sz + 1)
        return x;
      else {
        k -= a[a[x].lc].sz + 1;
        x = a[x].rc;
      }
    }
  }
  void insert(long long val) {
    long long x, y;
    split(rt, val, x, y);
    rt = merge(merge(x, NEW(val)), y);
  }
  void Del(long long val) {
    long long x, y, z;
    split(rt, val, x, z);
    split(x, val + 1, x, y);
    y = merge(a[y].lc, a[y].rc);
    rt = merge(merge(x, y), z);
  }
  long long Find(long long val) {
    long long res, x, y;
    split(rt, val + 1, x, y);
    res = a[x].sz + 1;
    rt = merge(x, y);
    return res;
  }
  long long Kth(long long rank) { return a[getk(rt, rank)].val; }
} T;
signed main() {
  n = read();
  for (; n--;) {
    long long op, x;
    op = read(), x = read();
    long long y = abs(x);
    sum += x;
    long long rk = T.Find(y);
    if (x > 0) {
      if (rk <= cnt) pre1 += (y - T.Kth(cnt));
      if (rk <= cnt + 1) pre2 += (y - T.Kth(cnt + 1));
      T.insert(y);
      if (op == 1) {
        cnt++;
        pre1 += T.Kth(cnt);
        pre2 += T.Kth(cnt + 1);
        S.insert(y);
      }
      if (T.Find(*S.begin()) == cnt)
        ans = sum + pre2 - *S.begin();
      else
        ans = sum + pre1;
    } else {
      if (rk <= cnt) pre1 -= (y - T.Kth(cnt + 1));
      if (rk <= cnt + 1) pre2 -= (y - T.Kth(cnt + 2));
      T.Del(y);
      if (op == 1) {
        pre1 -= T.Kth(cnt);
        pre2 -= T.Kth(cnt + 1);
        cnt--;
        S.erase(y);
      }
      if (cnt && T.Find(*S.begin()) == cnt)
        ans = sum + pre2 - *S.begin();
      else
        ans = sum + pre1;
    }
    printf("%lld\n", ans);
    puts("");
  }
  return 0;
}
