# 三分探索で解いたが想定解法をやってみる # まずHPはすべてK何回分かに書き換える # 回復必要な残り人数kとして、k*X > yならばyベホマラー、elseベホイミ N, K, X, Y = map(int, input().split()) A = list(map(int, input().split())) A2 = [(a-1+(K-1))//K for a in A] from collections import Counter counted = Counter(A2) counted_keys = [a for a in counted.keys()] counted_keys.sort() #print(A2) #print(counted) #print(counted_keys) ans = 0 cum = 0 k = N for key in counted_keys: if Y < k*X: ans += max(0, key-cum)*Y k -= counted[key] cum += key-cum else: ans += max(0, key-cum)*X k -= counted[key] #print('key', key, Y < k*X, 'ans', ans, 'k', k, 'cum', cum) print(ans)