using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { long cost1 = int.Parse(Reader.ReadLine()); long cost2 = int.Parse(Reader.ReadLine()); int inputCount = int.Parse(Reader.ReadLine()); Dictionary yoyaku = new Dictionary(); for (int i = 0; i < inputCount; i++) { int num = int.Parse(Reader.ReadLine()); if(yoyaku.ContainsKey(num)) { yoyaku[num]++; } else { yoyaku[num] = 1; } } long ans = (cost1 + cost2) * yoyaku.Select(a => a.Value - 1).Sum(); Console.WriteLine(ans); } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 30000 50000 5 402 402 605 605 605 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }