using System; using System.Collections.Generic; using System.Linq; class Program { public void Solve() { int P1 = int.Parse(Console.ReadLine()); int P2 = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); List R = new List(); for (int i = 0; i < N; i++) { R.Add(int.Parse(Console.ReadLine())); } int sonshitsu = 0; foreach (var item in R.Distinct()) { var count = R.Where(x => x == item).Count(); sonshitsu += (R.Where(x => x == item).Count() - 1) * (P1 + P2); } Console.WriteLine(sonshitsu); } static void Main() { var solver = new Program(); solver.Solve(); } }