#include <iostream> #include <deque> using namespace std;
int main() { ios::sync_with_stdio(false); cin.tie(nullptr);
deque<pair<long long, long long>> dq; // 存储(值,数量)对
int Q;
cin >> Q;
while (Q--) {
int type;
cin >> type;
if (type == 1) {
long long x, c;
cin >> x >> c;
dq.push_back({x, c}); // 添加到队尾
} else {
long long k;
cin >> k;
long long sum = 0;
while (k > 0) {
auto &front = dq.front();
long long take = min(k, front.second);
sum += take * front.first;
front.second -= take;
k -= take;
if (front.second == 0) {
dq.pop_front(); // 如果取完了就弹出
}
}
cout << sum << "\n";
}
}
return 0;
}