from collections import defaultdict p1 = int(input()) p2 = int(input()) N = int(input()) rec = defaultdict(int) for i in range(N): r = int(input()) rec[r] += 1 ans = 0 for v in rec.values(): ans += (v - 1) * (p1 + p2) print(ans)