from collections import Counter P = [int(input()) for _ in range(2)] N = int(input()) c = Counter(int(input()) for _ in range(N)) ans = sum(v - 1 if v >= 2 else 0 for v in c.values()) * sum(P) print(ans)