#include int main(){ int pay1, pay2; int N, i, num; int room[1000] = {0}; int money = 0; scanf("%d%d%d\n", &pay1, &pay2, &N); for(i = 0; i < N; i++){ scanf("%d", &num); room[num]++; if(room[num] > 1){ money += pay1 + pay2; room[num]--; } } printf("%d\n", money); return 0; }