use std::io::*; use std::str::FromStr; #[allow(dead_code)] fn get_line() -> String { let stdin = stdin(); let mut line = String::new(); stdin.lock().read_line(&mut line).expect("io error."); line.trim().to_string() } #[allow(dead_code)] fn cast(s: &str) -> T { s.parse().ok().expect("parse error.") } #[allow(dead_code)] fn get_vec() -> Vec { (&get_line()).split(' ').map(cast::).collect() } /* ---------- ここまでテンプレ ---------- */ fn main() { let p = cast::(&get_line()) + cast::(&get_line()); let n: u64 = cast(&get_line()); let mut cnt = [0u64; 1000]; for _ in 0..n { let r: usize = cast(&get_line()); cnt[r] += 1; } let mut ans = 0; for i in 1..1000 { if cnt[i] > 1 {ans += (cnt[i] - 1) * p}; } println!("{}", ans); }