package main import ( "fmt" "bufio" "os" "sort" ) func main() { r := bufio.NewReader(os.Stdin) w := bufio.NewWriter(os.Stdout) defer w.Flush() var N, K, X, Y int fmt.Fscan(r, &N, &K, &X, &Y) a := make([]int, N) for i := 0; i < N; i++ { fmt.Fscan(r, &a[i]) } sort.Ints(a) h, m := 1, 0 i := sort.Search(N, func(i int) bool {return a[i] > h}) var n, minh int if i < N { n = N - i minh = a[i] - h } else { n = 0 minh = 0 } for n > 0 { var v int if n * X > Y { v = Y } else { v = n * X } p := (K - 1 + minh) / K m += p * v h += K * p i = sort.Search(N, func(i int) bool {return a[i] > h}) if i < N { n = N - i minh = a[i] - h } else { n = 0 minh = 0 } } fmt.Fprintln(w, m) }