#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int p1,p2; cin >> p1 >> p2; int N; cin >> N; vector room(1000, 0); rep(i,N){ int r; cin >> r; room[r]++; } ll ans = 0; rep(i,1000) if(room[i] > 0) ans += (room[i] - 1) * (p1 + p2); cout << ans << endl; }