#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000000;
void build(long long* tree, int vertex, int left, int right) {
  if (left == right) {
    tree[vertex] = -left;
    return;
  }
  int treeMid = (left + right) / 2;
  build(tree, vertex * 2, left, treeMid);
  build(tree, vertex * 2 + 1, treeMid + 1, right);
  tree[vertex] = min(tree[vertex * 2], tree[vertex * 2 + 1]);
}
void pushdown(long long* tree, long long* tag, int vertex) {
  if (tag[vertex]) {
    tag[vertex * 2] += tag[vertex];
    tag[vertex * 2 + 1] += tag[vertex];
    tree[vertex * 2] += tag[vertex];
    tree[vertex * 2 + 1] += tag[vertex];
    tag[vertex] = 0;
  }
}
void update(long long* tree, long long* tag, int vertex, int left, int right,
            int treeLeft, int treeRight, int value) {
  if (treeLeft <= left && right <= treeRight) {
    tag[vertex] += value, tree[vertex] += value;
    return;
  }
  pushdown(tree, tag, vertex);
  int treeMid = (left + right) / 2;
  if (treeLeft <= treeMid) {
    update(tree, tag, vertex * 2, left, treeMid, treeLeft, treeRight, value);
  }
  if (treeRight > treeMid) {
    update(tree, tag, vertex * 2 + 1, treeMid + 1, right, treeLeft, treeRight,
           value);
  }
  tree[vertex] = min(tree[vertex * 2], tree[vertex * 2 + 1]);
}
long long query(long long* tree, long long* tag, int vertex, int left,
                int right, int treeLeft, int treeRight) {
  if (treeLeft <= left && right <= treeRight) {
    return tree[vertex];
  }
  if (treeRight < left || treeLeft > right) {
    return 1ll << 60;
  }
  pushdown(tree, tag, vertex);
  int treeMid = (left + right) / 2;
  return min(query(tree, tag, vertex * 2, left, treeMid, treeLeft, treeRight),
             query(tree, tag, vertex * 2 + 1, treeMid + 1, right, treeLeft,
                   treeRight));
}
int main() {
  int q;
  long long *tree, *tag;
  tree = new long long[(MAXN + 5) * 4];
  tag = new long long[(MAXN + 5) * 4];
  cin >> q;
  build(tree, 1, 1, MAXN);
  int *t, *d;
  t = new int[MAXN + 5];
  d = new int[MAXN + 5];
  for (int i = 1; i <= q; i++) {
    char operation;
    cin >> operation;
    if (operation == '+') {
      cin >> t[i] >> d[i];
      update(tree, tag, 1, 1, MAXN, t[i], MAXN, d[i]);
    } else if (operation == '-') {
      int temp;
      cin >> temp;
      update(tree, tag, 1, 1, MAXN, t[temp], MAXN, -d[temp]);
    } else if (operation == '?') {
      int temp;
      cin >> temp;
      long long x1 = query(tree, tag, 1, 1, MAXN, temp, temp),
                x2 = min(0ll, query(tree, tag, 1, 1, MAXN, 1, temp - 1));
      cout << x1 - x2 + 1 << endl;
    }
  }
}
