#include <iostream>
#include <map>
typedef long long ll;
std::map<ll, int> mp;
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int n, q;
ll more = 0, all = 0;
std::cin >> n;
for (int i = 1, x; i <= n; ++i) {
std::cin >> x;
mp[x]++;
all += x;
}
std::cin >> q;
while (q--) {
std::string type;
ll x, y;
std::cin >> type >> x;
if (type[0] == 'I') more += x;
else {
std::cin >> y;
x -= more, y -= more;
if (x != y && mp.count(x)) {
all += (y - x) * mp[x];
mp[y] += mp[x];
mp.erase(x);
}
}
std::cout << all + more * n << '\n';
}
return 0;
}
record
样例可过,