using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoder_586 { class Program { static void Main(string[] args) { int p1 = int.Parse(Console.ReadLine()); int p2 = int.Parse(Console.ReadLine()); int n = int.Parse(Console.ReadLine()); int count = 0; int[] r = new int[n]; for (int i = 0; i < n; i++) { r[i] = int.Parse(Console.ReadLine()); } Array.Sort(r); for (int i = 1; i < n; i++) { if (r[i - 1] == r[i]) { count++; } } Console.WriteLine(count * (p1 + p2)); Console.ReadLine(); } } }