#include int main() { int P,FP,N; std::cin >> P >> FP >> N; int* R = new int[N]; for (int i = 0; i < N; i++) { std::cin >> R[i]; } int LostMoney = 0; if (N >= 2) { for (int i = 1; i < N; i++) { for (int j = 0; j < i - 1; j++) { if (R[i] == R[j]) { LostMoney += P + FP; } } } } std::cout << LostMoney << std::endl; return 0; }