yuki_hotel_price = int(input()) transfer_hotel_price = int(input()) booking_num = int(input()) booking_room_numbers = [] transferred_room_numbers = [] for i in range(booking_num): booking_room_numbers.append(int(input())) loss_amount = 0 for num in booking_room_numbers: # 振替済みなら何もしない if num in transferred_room_numbers: continue # 重複予約 double_booking_num = booking_room_numbers.count(num) if double_booking_num >= 2: # 損失費用の加算 loss_amount += (double_booking_num - 1)*yuki_hotel_price + (double_booking_num - 1)*transfer_hotel_price # 振替済みに追加 transferred_room_numbers.append(num) print(loss_amount)