#include void main(void) { int hotelA = 0; int input = scanf("%d ",&hotelA); if(input == 2){ printf("hotelAの入力ミス"); } int hotelB = 0; scanf("%d ",&hotelB); int reservation = 0; scanf("%d ",&reservation); int roomNumber[reservation]; for(int i = 0 ; i < reservation;i++){ scanf("%d\n",&reservation); } int loss = 0; for(int i = 0 ; i < reservation;i++){ if(roomNumber[i] == 0){ continue; } for(int j = i ; j < reservation ; j++){ if(roomNumber[j] == 0){ continue; } if(roomNumber[i] == roomNumber[j]){ roomNumber[j] = 0; loss += hotelA+hotelB; } } } printf("%d",loss); }