#include <bits/stdc++.h>
#pragma comment(linker, "/STACK: 40000000")
using namespace std;
long long int st_minpref[2200000];
long long int st_sum[2200000];
long long int qt[300005];
long long int qd[300005];
void upd(long long int node) {
  st_sum[node] = st_sum[((node) << 1)] + st_sum[(((node) << 1) + 1)];
  st_minpref[node] =
      min(st_minpref[((node) << 1)],
          st_sum[((node) << 1)] + st_minpref[(((node) << 1) + 1)]);
}
void inc(long long int pos, long long int delta) {
  long long int node = ((pos) + (1 << 20));
  st_sum[node] += delta;
  st_minpref[node] += delta;
  while (true) {
    node = ((node) >> 1);
    upd(node);
    if (node == 1) return;
  }
}
pair<long long int, long long int> minprefix(long long int threshold,
                                             long long int l, long long int r,
                                             long long int node,
                                             long long int accum) {
  if (l == r) return {l, accum + st_sum[node]};
  long long int mid = (l + r) / 2;
  if (st_minpref[((node) << 1)] == st_minpref[node] || mid + 1 > threshold) {
    return minprefix(threshold, l, mid, ((node) << 1), accum);
  }
  pair<long long int, long long int> rmp =
      minprefix(threshold, mid + 1, r, (((node) << 1) + 1),
                accum + st_sum[((node) << 1)]);
  long long int rmp_pos = rmp.first;
  long long int rmp_sum = rmp.second;
  if (accum + st_minpref[((node) << 1)] > rmp_sum) return rmp;
  return minprefix(threshold, l, mid, ((node) << 1), accum);
}
long long int minprefix(long long int threshold) {
  return minprefix(threshold, 0, (1 << 20) - 1, 1, 0).first;
}
long long int sum(long long int sl, long long int sr, long long int l,
                  long long int r, long long int node) {
  if (sl <= l && r <= sr) return st_sum[node];
  if (r < sl || l > sr) return 0;
  long long int mid = (l + r) / 2;
  return sum(sl, sr, l, mid, ((node) << 1)) +
         sum(sl, sr, mid + 1, r, (((node) << 1) + 1));
}
long long int sum(long long int sl, long long int sr) {
  return sum(sl, sr, 0, (1 << 20) - 1, 1);
}
void debug_query(long long int threshold) {
  long long int make_pair = minprefix(threshold - 1);
  cout << threshold << " [" << sum(threshold, threshold) << "]"
       << " - " << make_pair << ":" << threshold << " = "
       << 1 + sum(make_pair + 1, threshold) << endl;
}
void query(long long int threshold) {
  long long int make_pair = minprefix(threshold - 1);
  cout << 1 + sum(make_pair + 1, threshold) << "\n";
}
void solve() {
  for (long long int i = ((0) + (1 << 20)); i < ((1 << 20) + (1 << 20)); i++) {
    st_sum[i] = -1;
    st_minpref[i] = -1;
  }
  for (long long int i = ((0) + (1 << 20)) - 1; i >= 1; i--) {
    upd(i);
  }
  long long int q;
  cin >> q;
  for (long long int qi = 1; qi <= q; qi++) {
    string s;
    cin >> s;
    if (s == "+") {
      cin >> qt[qi] >> qd[qi];
      inc(qt[qi], qd[qi]);
    }
    if (s == "-") {
      long long int rqi;
      cin >> rqi;
      inc(qt[rqi], -qd[rqi]);
    }
    if (s == "?") {
      long long int qth;
      cin >> qth;
      query(qth);
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  solve();
  return 0;
}
