p1=int(input()) p2=int(input()) n=int(input()) l=list(int(input()) for i in range(n)) count=0 for i in range(1,n): for j in range(i): if l[i]==l[j]: count+=1 break cost=count*(p1+p2) print(cost)