#include #include #include #include #include #include using namespace std; #define diff(x,y) ((x > y) ? (x - y) : (y - x)) int main() { int p1, p2, n; int x; vector r(1000, 0); int ans = 0; cin >> p1 >> p2 >> n; for (int i = 0; i < n; i++) { cin >> x; r[x]++; if (r[x] > 1) ans += p1 + p2; } cout << ans << endl; return 0; }