#include using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) int main() { ios::sync_with_stdio(false); cin.tie(0); int p1, p2, n; cin >> p1 >> p2 >> n; int r, cnt[1000] = {};; REP(i, n) { cin >> r; cnt[r]++; } int ans = 0; REP(i, 1000) { if (cnt[i] > 1) ans += (cnt[i] - 1) * (p1 + p2); } cout << ans << endl; return 0; }