#include #include #include #include #include #include #include #include #include #include using namespace std; #define INIT cin.tie(0); ios::sync_with_stdio(false); #define FOR(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) for(int i = 0; i < n; i++) int main() { INIT; int p1, p2, n; cin >> p1 >> p2 >> n; int R[n]; REP(i, n) cin >> R[i]; int p = p1 + p2; vector v; int f; REP(i, n){ f = 0; REP(j, v.size()){ if(R[i] == v[j]){ f = 1; break; } } if(f == 0) v.push_back(R[i]); } int cnt, total = 0; REP(i, v.size()){ cnt = 0; REP(j, n){ if(v[i] == R[j]) cnt++; } if(cnt >= 2) total += p * (cnt - 1); } cout << total << endl; return 0; }