#include using namespace std; int main() { int P1, P2, N, R; cin >> P1 >> P2 >> N; vector V(1000); while (cin >> R) V.at(R)++; int ans = 0; for (int i = 0; i < 1000; i++) if (V.at(i) > 1) ans += (V.at(i) - 1) * (P1 + P2); cout << ans << "\n"; }