def main(): p1 = int(input()) p2 = int(input()) n = int(input()) r = {} for i in range(n): j = int(input()) if j in r: r[j] += 1 else: r[j] = 0 ans = (p1+p2)*sum(r.values()) print(ans) if __name__ == "__main__": main()