package main import "fmt" func main() { var py, pa, n int fmt.Scan(&py, &pa, &n) r := make(map[int]int, 0) for i := 0; i < n; i++ { var room int fmt.Scan(&room) r[room]++ } ans := 0 for _, v := range r { ans += (v-1)*py + (v-1)*pa } fmt.Println(ans) }