#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,n) for(int i=0;i( \ ( std::ostringstream() << std::dec << x ) ).str() #define ALL(s) (s).begin(), (s).end() using namespace std; typedef long long unsigned int llu; typedef long long ll; int main (){ int p1,p2,n; while(cin >> p1 >> p2 >> n){ vector s; int ans = 0; REP(i,n){ int x; cin >>x; if(find(ALL(s), x) == s.end()){ s.push_back(x); }else{ ans = ans + p1 + p2; } } s.clear(); cout << ans << endl; } return 0; }