#include using namespace std; using ll = long long; using P = pair; #define rep(i,n) for(int i=0;i> p1 >> p2 >> n; map r; int a; rep(i,n){ cin >> a; r[a]++; } int ans = 0; for (auto x:r){ ans += (p1+p2) * (x.second-1); } cout << ans << endl; return 0; }