#include <iostream>
#include <vector>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<class T> using Set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
  int q;
  cin >> q;

  Set<pair<long long, int>> st;
  vector<pair<long long, int>> tmp;
  long long u = 0;

  for (int i = 0; i < q; i++) {
    int t;
    long long x;
    cin >> t >> x;

    if (t == 1) {
      int j = tmp.size();
      tmp.emplace_back(x - u, j);
      st.insert(make_pair(x - u, j));
    } else if (t == 2) {
      st.erase(tmp[x - 1]);
    } else {
      u += x;
    }
    long long ok = 0;
    long long ng = 2e5;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      int cnt = st.size() - st.order_of_key(make_pair(mid - u, 0));
      if (cnt >= mid) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cout << ok << endl;
  }
}