#include #include #include #include #include #include #include #include #include int main() { long long p1, p2; long long n; std::map r; std::cin >> p1 >> p2 >> n; for (size_t i = 0; i < n; i++) { int room; std::cin >> room; r[room]++; } long long count = 0; for (auto i = r.begin(); i != r.end(); i++) { count += i->second - 1; } std::cout << count * (p1 + p2) << std::endl; return 0; }