collections.Counter()

  • + 0 comments

    x = int(input()) n = list(map(int, input().split())) c = int(input()) data = [tuple(map(int, input().split())) for _ in range(c)] amount=0 for i in range(0,c): if data[i][0] in n: amount+=data[i][1] n.remove(data[i][0]) else: continue

    print(amount)