#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n;
class ordered_set {
 private:
  static const long long LB = INT_MIN, RB = INT_MAX;
  struct node {
    long long cnt = 0, sum = 0;
    long long lo = RB, hi = LB;
    node *lid, *rid;
  };
  node *root = new node();
  inline void create_node(node *par, long long dir) {
    if (dir == 0)
      par->lid = new node();
    else
      par->rid = new node();
  }
  long long get_cnt(node *id) { return id == nullptr ? 0 : id->cnt; }
  long long get_sum(node *id) { return id == nullptr ? 0 : id->sum; }
  long long get_min(node *id) { return id == nullptr ? RB : id->lo; }
  long long get_max(node *id) { return id == nullptr ? LB : id->hi; }
  void update(node *id, long long l, long long r, long long i, long long hs) {
    if (l == r) {
      if (id->cnt == 0 && hs == -1) return;
      id->cnt += hs;
      id->sum += i * hs;
      id->lo = id->cnt ? i : RB;
      id->hi = id->cnt ? i : LB;
      return;
    }
    if (i <= ((l + r) >> 1)) {
      if (id->lid == nullptr) create_node(id, 0);
      update(id->lid, l, ((l + r) >> 1), i, hs);
    } else {
      if (id->rid == nullptr) create_node(id, 1);
      update(id->rid, ((l + r) >> 1) + 1, r, i, hs);
    }
    id->cnt = get_cnt(id->lid) + get_cnt(id->rid);
    id->sum = get_sum(id->lid) + get_sum(id->rid);
    id->lo = min(get_min(id->lid), get_min(id->rid));
    id->hi = max(get_max(id->lid), get_max(id->rid));
  }
  long long get(node *id, long long l, long long r, long long u, long long v) {
    if (id == nullptr || r < u || v < l) return 0;
    if (u <= l && r <= v) return id->sum;
    return get(id->lid, l, ((l + r) >> 1), u, v) +
           get(id->rid, ((l + r) >> 1) + 1, r, u, v);
  }
  long long trace(node *id, long long l, long long r, long long k) {
    if (id == nullptr) return RB;
    if (l == r)
      return id->cnt ? l : RB;
    else
      return get_cnt(id->lid) >= k
                 ? trace(id->lid, l, ((l + r) >> 1), k)
                 : trace(id->rid, ((l + r) >> 1) + 1, r, k - get_cnt(id->lid));
  }
  long long climb(node *id, long long l, long long r, long long val,
                  long long hs) {
    if (id == nullptr) return RB;
    if (l == r) return id->cnt ? l : RB;
    return hs == 0 ? id->lid != nullptr && get_max(id->lid) >= val
                         ? climb(id->lid, l, ((l + r) >> 1), val, hs)
                         : climb(id->rid, ((l + r) >> 1) + 1, r, val, hs)
           : id->rid != nullptr && get_min(id->rid) <= val
               ? climb(id->rid, ((l + r) >> 1) + 1, r, val, hs)
               : climb(id->lid, l, ((l + r) >> 1), val, hs);
  }
  void clear(node *id) {
    if (id == nullptr) return;
    clear(id->lid);
    clear(id->rid);
    delete id;
    id = nullptr;
  }

 public:
  ordered_set() {}
  long long end() { return RB; }
  long long size() { return root->cnt; }
  bool empty() { return !size(); }
  void insert(const long long &i) { update(root, LB, RB, i, 1); }
  void erase(const long long &i) { update(root, LB, RB, i, -1); }
  void clear() {
    clear(root->lid);
    clear(root->rid);
    root = new node();
  }
  long long order_of_key(const long long &k) {
    return get(root, LB, RB, LB, k);
  }
  long long find_by_order(const long long &k) {
    return root->cnt >= k ? trace(root, LB, RB, k) : RB;
  }
  long long lower_bound(const long long &val) {
    return climb(root, LB, RB, val, 0);
  }
  long long upper_bound(const long long &val) {
    return climb(root, LB, RB, val, 1);
  }
  long long count(long long l, long long r) { return get(root, LB, RB, l, r); }
} st;
set<long long> f;
vector<long long> res;
int32_t main() {
  ios::sync_with_stdio(0);
  cin >> n;
  long long s = 0;
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    long long tp, d;
    cin >> tp >> d;
    if (d > 0)
      st.insert(d), s++;
    else
      st.erase(-d), s--;
    if (tp == 0) {
      if (d > 0)
        f.insert(d);
      else
        f.erase(-d);
    } else if (d > 0)
      cnt++;
    else
      cnt--;
    long long cur = st.count(-1e9, 1e9);
    if (cnt) {
      long long mf = f.size() ? *(f.rbegin()) : -0x3f3f3f3f;
      long long g = st.find_by_order(s - cnt + 1), og = g;
      g = st.count(g, 1e9);
      if (mf >= og)
        cur += max(0LL, g);
      else
        cur += max(0LL, (g - og) + max(0LL, mf));
      res.emplace_back(cur);
    } else
      res.emplace_back(cur);
  }
  for (long long i : res) cout << i << '\n';
}
