using System; using System.Linq; using System.Collections.Generic; class Program { static void Main() { var p1 = int.Parse(Console.ReadLine()); var p2 = int.Parse(Console.ReadLine()); var n = int.Parse(Console.ReadLine()); var dic = new Dictionary(); for (int i = 0; i < n; i++) { var r = int.Parse(Console.ReadLine()); if (dic.ContainsKey(r)) { dic[r]++; } else { dic[r] = 1; } } var ans = 0; foreach (var item in dic) { if (item.Value > 1) { ans += (p1 + p2) * (item.Value - 1); } } Console.WriteLine(ans); } }