p1 = int(input()) p2 = int(input()) n = int(input()) used = set() ans = 0 for i in range(n): r = int(input()) if r in used: ans += p1+p2 used.add(r) print(ans)