collections.Counter()

  • + 0 comments

    X=int(input())
    S=list(map(int,input().split())) N=int(input()) li=[] for i in range(N): SP=[int(n) for n in input().split()] li.append(SP) summ=0 for i in li: if(i[0] in S): summ += i[1] S.remove(i[0]) print(summ)