// #define _GLIBCXX_DEBUG #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { // Input int P1, P2, N; cin >> P1 >> P2 >> N; vector R(N); rep(i, N) cin >> R[i]; // Calculate Losses set book; int ans = 0; rep(i, N) { if (!book.count(R[i])) book.insert(R[i]); else ans += P1 + P2; } // Output cout << ans << endl; }