e = int(input()) l = int(input()) dic = {} n = int(input()) for i in range(n): r = int(input()) if r in dic: dic[r] += 1 else: dic[r]= 1 loss = 0 for v in dic.values(): if v >= 2: loss += (e * (v - 1) + l * (v - 1)) print(loss)