collections.Counter()

  • + 0 comments
    num_shoes = input()
    
    size_list = input().split()
    
    customers_count = int(input())
    
    sale_dict = dict()
    
    total = 0
    
    for item in range(customers_count):
        sale_dict.update({f'{item}' : (input().split())})
    
    for x,y in sale_dict.items():
        if y[0] in size_list:
            total += int(y[1])
            size_list.remove(y[0])
    
    print(total)