#!/usr/bin/env python # -*- coding: utf-8 -*- def remove_deplicates(x): y = [] for i in x: if i not in y: y.append(i) return y yuki_charge = int(input()) furi_charge = int(input()) reserve_count = int(input()) reserve_room = [] c = 0 for i in range(0, reserve_count): reserve_room.append(int(input())) room_collection = remove_deplicates(reserve_room) for room in room_collection: count_room_res = reserve_room.count(room) if count_room_res > 1: c += (yuki_charge + furi_charge) * (count_room_res - 1) print(c)