package yukicoder.No586; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int flg[] = new int[1000]; Arrays.fill(flg, 0); int P1 = in.nextInt(); int P2 = in.nextInt(); int N = in.nextInt(); int cost = 0; for (int i = 0; i < N; i++) { int R = in.nextInt(); if (flg[R] != 0) { cost += P1+P2; } flg[R] = 1; } System.out.println(cost); } }