📅  最后修改于: 2022-03-11 14:46:16.880000             🧑  作者: Mango
num = int(input())
data = set(map(int, input().split()))
operations = int(input())
for x in range(operations):
oper = input().split()
if oper[0] == "remove":
data.remove(int(oper[1]))
elif oper[0] == "discard":
data.discard(int(oper[1]))
else:
data.pop()
print(sum(data))