#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; const ll inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; int p1, p2, n, x, ans; int main() { cin >> p1 >> p2 >> n; vector a(1000); for (int i = 0; i < n; i++) { cin >> x; a[x]++; } for (int i = 0; i < 1000; i++) { if (a[i] >= 2) ans += (p1 + p2) * (a[i] - 1); } cout << ans << endl; }