/* -*- coding: utf-8 -*- * * 586.cc: No.586 ダブルブッキング - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int RN = 1000; /* typedef */ typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ /* subroutines */ int bks[RN]; /* main */ int main() { int p0, p1, n; scanf("%d%d%d", &p0, &p1, &n); for (int i = 0; i < n; i++) { int ri; scanf("%d", &ri); bks[ri]++; } int ob = 0; for (int i = 0; i < RN; i++) if (bks[i] > 1) ob += bks[i] - 1; printf("%d\n", ob * (p0 + p1)); return 0; }