#include #include #include #define REP(i, a, b) for (int i = int(a); i < int(b); i++) #define dump(s) cerr << __LINE__ << "\t:" << #s << " = " << (s) << endl using namespace std; int main () { long long P1, P2; cin >> P1 >> P2; int N; cin >> N; vector R(1000, 0); REP (i, 0, N) { int Ri; cin >> Ri; R[Ri]++; } long long ans = 0; for (auto &r : R) { if (r > 1) { ans += (r - 1) * (P1 + P2); } } cout << ans << endl; return 0; }