#include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 #define INF 1000000000 using namespace std; int main(void) { int p1, p2; int n; int r; int dp[1000]; int count = 0; cin >> p1 >> p2 >> n; FOR(i, 1, n) { cin >> r; dp[r]++; } FOR(i, 1, 999) { if (dp[i] >= 2) { count += (dp[i] - 1)*(p1 + p2); } } cout << count << endl; return 0; }