#include <iostream>
#include <stack>
using namespace std;
int main() {
int m;
int cur = 0, sum = 0;
stack<pair<int, int>> st;
scanf("%d", &m);
while (m--) {
int q;
scanf("%d", &q);
if (q == 1) {
int t, w;
scanf("%d%d", &t, &w);
cur += t, sum += w;
st.push({cur, sum});
} else {
int p;
scanf("%d", &p);
while (st.size() and st.top().first > cur - p) st.pop();
if (st.size()) cur = st.top().first, sum = st.top().second;
else cur = sum = 0;
}
printf("%d\n", sum);
}
return 0;
}