p1,p2=int(input()),int(input()) a=[int(input()) for _ in range(int(input()))] print((p1+p2)*sum(a.count(i)-1 for i in set(a)))