After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency.

These were the great news for Alice, whose grandfather got into Bitcoin mining in 2013, and accumulated a lot of them throughout the years. Unfortunately, when paying something in bitcoin everyone can see how many bitcoins you have in your public address wallet. 

This worried Alice, so she decided to split her bitcoins among multiple different addresses, so that every address has at most $x$ satoshi (1 bitcoin = $10^8$ satoshi). She can create new public address wallets for free and is willing to pay $f$ fee in satoshi per transaction to ensure acceptable speed of transfer. The fee is deducted from the address the transaction was sent from. Tell Alice how much total fee in satoshi she will need to pay to achieve her goal.


-----Input-----

First line contains number $N$ ($1 \leq N \leq 200\,000$) representing total number of public addresses Alice has.

Next line contains $N$ integer numbers $a_i$ ($1 \leq a_i \leq 10^9$) separated by a single space, representing how many satoshi Alice has in her public addresses.

Last line contains two numbers $x$, $f$ ($1 \leq f < x \leq 10^9$) representing maximum number of satoshies Alice can have in one address, as well as fee in satoshies she is willing to pay per transaction. 


-----Output-----

Output one integer number representing total fee in satoshi Alice will need to pay to achieve her goal.


-----Example-----
Input
3
13 7 6
6 2

Output
4



-----Note-----

Alice can make two transactions in a following way:

0. 13 7 6 (initial state)

1. 6 7 6 5 (create new address and transfer from first public address 5 satoshies)

2. 6 4 6 5 1 (create new address and transfer from second address 1 satoshi)

Since cost per transaction is 2 satoshies, total fee is 4.

Difficulty: MEDIUM
Tags: Implementation

Starter code:

Solutions:
def g(q, x, f, a):
	if (a + q - 1) // q - (q - 1) * f <= x:
		return True
	else:
		return False
s = input()
n = int(s)
s = input()
y = s.split()
s = input()
s = s.split()
x = int(s[0])
f = int(s[1])
ans = 0
for i in y:
	ans += (int(i) + f - 1) // (x + f)
print(ans * f)


import math
n = int(input())
l = list(map(int, input().split()))
(x, f) = map(int, input().split())
total = 0
for j in range(n):
	if l[j] > x:
		total += math.ceil((l[j] - x) / (x + f))
print(total * f)


n = int(input())
tab = list(map(int, input().split()))
(p, f) = map(int, input().split())
wyn = 0
for x in tab:
	diff = int(x / (p + f))
	if x % (p + f) > p:
		diff += 1
	wyn += diff * f
print(wyn)


import math
NN = int(input())
AI = list(map(int, input().split()))
(XX, FF) = list(map(int, input().split()))
length = len(AI)
extra = 0
for xx in AI:
	if xx > XX:
		extra += math.ceil((xx - XX) / (XX + FF))
print(extra * FF)


import math
input()
a = list(map(int, input().split()))
(x, y) = list(map(int, input().split()))
s = 0
for i in a:
	if i > x:
		s += math.ceil((i - x) / (x + y))
print(int(s * y))


n = int(input())
coshelki = [int(i) for i in input().split()]
(x, f) = (int(i) for i in input().split())
sum = 0
for i in coshelki:
	perevody = i // (x + f)
	if i - perevody * (x + f) > x:
		perevody += 1
	sum += perevody
print(f * sum)


n = int(input())
l = list(map(int, input().split()))
(x, f) = map(int, input().split())
c = 0
for i in l:
	y = i - x
	if y > 0:
		a = y // (x + f)
		b = y / (x + f)
		if a == b:
			c = c + a
		else:
			c = c + a + 1
print(f * c)


import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
(x, f) = map(int, input().split())
fee = 0
temp = 0
for i in a:
	if i > x:
		temp = int(math.ceil((i - x) / (x + f)))
		temp = max(1, temp)
		fee = fee + temp * f
print(fee)


n = int(input())
l = list(map(int, input().split()))
(x, f) = map(int, input().split())
k = 0
for i in range(n):
	if l[i] > x:
		k += (l[i] - x - 0.1) // (x + f) + 1
print(int(k * f))


import math
N = int(input())
a = list(map(int, input().split()))
(x, f) = map(int, input().split())
s = x + f
o = 0
for j in a:
	if j > x:
		o += math.ceil((j - x) / s)
print(o * f)


n = int(input())
a = [int(x) for x in input().split()]
(x, f) = [int(x) for x in input().split()]
res = 0
for i in a:
	if i > x:
		res += f * int(i / (f + x))
		if i % (f + x) > x:
			res += f
print(res)


n = int(input())
l = list(map(int, input().split()))
(x, f) = map(int, input().split())
b = x + f
ans = 0
for i in range(n):
	a = l[i] - x
	if a % b == 0:
		ans += a // b
	else:
		ans += a // b + 1
print(ans * f)


I = lambda : map(int, input().split())
n = int(input())
a = list(I())
a.sort(reverse=True)
(x, f) = I()
summ = 0
for i in range(n):
	if a[i] > x:
		r = (a[i] - x) // (x + f)
		if (a[i] - x) % (x + f):
			r += 1
		summ += f * r
	else:
		break
print(summ)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 6 + 7

def fee(p):
	return p // (x + f) * f + max(0, min(1, p % (x + f) - x)) * f
n = I()
a = L()
(x, f) = R()
ans = 0
for i in a:
	if i > x:
		ans += fee(i)
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
(x, f) = map(int, input().split())
ans = 0
for i in range(n):
	left = a[i] - x
	if a[i] <= x:
		left = 0
	ans += math.ceil(left / (f + x))
print(f * ans)


import sys
from sys import stdin, stdout
n = int(stdin.readline())
coins = list(map(int, stdin.readline().split(' ')))
coins.sort()
(x, f) = list(map(int, stdin.readline().split(' ')))
flag1 = True
for i in range(len(coins)):
	if coins[i] > x:
		coins = coins[i:]
		flag1 = False
		break
if flag1:
	coins = []
ctr = 0

def mainkaam(e):
	nonlocal x, f
	t1 = e // (x + f)
	t2 = e % (x + f)
	if t2 > x:
		return t1 + 1
	else:
		return t1
for i in coins:
	ctr += mainkaam(i)
print(ctr * f)


n = int(input())
a = map(int, input().split())
(x, f) = map(int, input().split())
s = 0
for y in a:
	d = (y - x) // (x + f)
	y -= d * (x + f)
	if y > x:
		d += 1
	s += d
print(s * f)


n = int(input())
a = list(map(int, input().split()))
(maxVal, cost) = map(int, input().split())
newWallets = 0
for s in a:
	if s > maxVal:
		newWallets += (s + cost - 1) // (maxVal + cost)
print(newWallets * cost)


x = int(input())
l = list(map(int, input().split()))
(a, b) = map(int, input().split())
cnt = 0
for i in l:
	if i > a:
		cnt += b * (i // (a + b))
		i -= i // (a + b) * (a + b)
	if i - b > 0 and i > a and (i - b <= a):
		cnt += b
print(cnt)


import sys
input = sys.stdin.readline
from math import ceil
n = int(input())
pub_address = list(map(int, input().split()))
(x, f) = map(int, input().split())
fees = 0
for p in pub_address:
	if p > x:
		fees += int(ceil((p - x) / (f + x)))
print(fees * f)


import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
(x, f) = map(int, input().split())
k = 0
for i in range(n):
	if a[i] >= x + f:
		k += a[i] // (x + f)
		if a[i] % (x + f) > x:
			k += 1
	elif x < a[i] < x + f:
		k += 1
print(k * f)


import sys
import bisect
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans

def search(a, x):
	i = bisect.bisect_right(a, x)
	if i == 0:
		return -1
	return i - 1
n = int(input())
a = list(map(int, sys.stdin.readline().split(' ')))
(x, f) = map(int, sys.stdin.readline().split(' '))
ans = 0
for aa in a:
	if aa <= x:
		continue
	val = (aa - x) // (x + f)
	if val * (x + f) < aa - x:
		val += 1
	ans += val
print(f * ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


n = int(input())
a = input().split()
a = [int(x) for x in a]
(x, f) = input().split()
x = int(x)
f = int(f)
ans = 0
for i in a:
	ans += int((i + f - 1) / (x + f)) * f
print(ans)


import math
n = int(input())
a = [int(s) for s in input().split()]
(x, f) = map(int, input().split())
ans = 0
for i in range(n):
	if a[i] <= x:
		continue
	if a[i] // (x + f) > 0:
		ans += a[i] // (x + f) * f
		a[i] -= a[i] // (x + f) * (x + f)
		if a[i] <= x:
			continue
		ans += a[i] // x * f
	else:
		ans += a[i] // x * f
print(ans)


n = int(input())
rek = list(map(int, input().split()))
(mx, pay) = map(int, input().split())
ans = 0
import math
for i in rek:
	if i > mx:
		ans += pay * math.ceil((i - mx) / (mx + pay))
print(ans)


n = int(input())
l = list(map(int, input().split()))
(x, f) = [int(x) for x in input().split()]
num = 0
s = x + f
for i in range(n):
	if l[i] <= x:
		num += 0
	else:
		a = l[i] - x
		num += int((a + s - 1) / s)
print(num * f)


import math

def round_school(x):
	(i, f) = divmod(x, 1)
	return int(i + (f >= 0.5 if x > 0 else f > 0.5))
line1 = input()
line2 = input()
line3 = input()
addrs = list()
count = int(line1.strip())
for elem in line2.split():
	addrs.append(int(elem))
intline3 = list(map(int, line3.split()))
maxaddr = intline3[0]
fees = intline3[1]
idx = 0
s2 = 0
transactions = 0
val = 0.0
initiallen = len(addrs)
while idx < initiallen:
	if addrs[idx] > maxaddr and addrs[idx] <= maxaddr + fees:
		transactions = transactions + 1
	elif addrs[idx] > maxaddr + fees and addrs[idx] <= 2 * maxaddr + fees:
		transactions = transactions + 1
	elif addrs[idx] > 2 * maxaddr + fees:
		mult = int(math.floor(addrs[idx] / (maxaddr + fees)))
		transactions = transactions + mult
		val = addrs[idx] - mult * (maxaddr + fees)
		if val > maxaddr:
			if val > 2 + fees:
				transactions = transactions + 1
	idx = idx + 1
print(transactions * fees)


import math
n = int(input())
l = list(map(int, input().split()))
(x, f) = map(int, input().split())
ans = 0
for i in range(n):
	if l[i] <= x:
		continue
	else:
		c = math.ceil((l[i] - x) / (f + x))
		ans += f * c
print(ans)


n = int(input())
a = list(map(int, input().split()))
(x, f) = map(int, input().split())
ans = 0
for i in a:
	if i > x:
		ans += i // (x + f) * f
		if i % (x + f) > x:
			ans += f
print(ans)


import math
a = int(input())
b = input().split()
b = [int(i) for i in b]
c = input().split()
c = [int(i) for i in c]
output = 0
for i in b:
	output += (i + c[1] - 1) // (c[0] + c[1])
print(output * c[1])


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
a = inara()
(x, f) = invr()
ans = 0
for i in range(n):
	if a[i] > x:
		a[i] -= x
		cil = 1 + (a[i] - 1) // (x + f)
		cil *= f
		ans += cil
print(ans)


def binpow(a, b, c):
	if a <= b:
		return 0
	uk1 = 0
	uk2 = 1000000000
	while uk2 - uk1 > 1:
		if a - (uk2 + uk1) // 2 * (b + c) <= b:
			uk2 = (uk2 + uk1) // 2
		else:
			uk1 = (uk2 + uk1) // 2
	return uk2
n = int(input())
l = list(map(int, input().split()))
(f, x) = list(map(int, input().split()))
ans = 0
for i in range(n):
	ans += binpow(l[i], f, x) * x
print(ans)


import bisect
import math
n = int(input())
vallet = []
vallet = list(map(int, input().strip().split()))
(maxst, fee) = list(map(int, input().strip().split()))
vallet.sort()
index = bisect.bisect(vallet, maxst)
numsplit = 0
for i in range(index, len(vallet)):
	numsplit += math.ceil(float(vallet[i] - maxst) / (maxst + fee))
print(numsplit * fee)


import math
n = int(input())
ch = input().split()
a = list()
for i in range(n):
	a.append(int(ch[i]))
ch = input().split()
max1 = int(ch[0])
fee = int(ch[1])
a.sort(reverse=True)
result = 0
for i in range(n):
	if a[i] <= max1:
		break
	k = a[i] + fee
	result += math.ceil(k / (fee + max1)) - 1
print(result * fee)


n = int(input())
a = [int(el) for el in input().split()]
(x, f) = [int(el) for el in input().split()]
out = 0
for i in a:
	if (i - x) % (x + f) == 0 and i > x:
		out += int((i - x) / (x + f))
	elif i > x:
		out += int((i - x) / (x + f)) + 1
print(out * f)


import math
n = int(input())
a = list(map(int, input().split()))
s = 0
(m, f) = map(int, input().split())
for i in a:
	if i > m:
		s += math.ceil((i - m) / (f + m)) * f
print(s)


n = int(input())
a = list(map(int, input().split()))
(max, fee) = map(int, input().split())
total = 0
a.sort(reverse=True)
for i in range(n):
	if a[i] > max:
		num = -(-(a[i] - max) // (max + fee))
		total = total + fee * num
	else:
		break
print(total)


from math import ceil

def problem(in1, in2, in3):
	n = int(in1)
	balances = list(map(int, in2.split()))
	limit = list(map(int, in3.split()))[0]
	fee = list(map(int, in3.split()))[1]
	tx_size = limit + fee
	tx_count = 0
	for (index, balance) in enumerate(balances):
		tx_needed = ceil((balance - limit) / tx_size)
		tx_count += tx_needed
	return tx_count * fee
in1 = input()
in2 = input()
in3 = input()
result = problem(in1, in2, in3)
print(result)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import *
from bisect import *
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = I()
ls = lint()
(x, f) = tup()
ans = 0
for i in ls:
	if i > x:
		ans += ceil((i - x) / (x + f))
print(ans * f)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


num_addresses = int(input())
addresses = list(map(int, input().split()))
(max_satoshies, fee) = map(int, input().split())
movements = 0
for address in addresses:
	to_move = address - max_satoshies
	if to_move > 0:
		movements += to_move // (max_satoshies + fee)
		if to_move % (max_satoshies + fee) != 0:
			movements += 1
print(movements * fee)


N = int(input())
a = [int(i) for i in input().split()]
(x, f) = [int(i) for i in input().split()]
cost = int(0)
for i in range(N):
	if a[i] % (x + f) > x:
		extra = a[i] // (x + f) + 1
	elif a[i] % (x + f) <= x:
		extra = a[i] // (x + f)
	a[i] -= (x + f) * extra
	cost += f * extra
print(cost)


n = int(input())
publicAd = list(map(int, input().split(' ')))
(maxx, fee) = list(map(int, input().split(' ')))
count = 0
for temp in publicAd:
	if temp > maxx:
		t = (temp - maxx) / (maxx + fee)
		count += 1 + (int(t) if t > 1 else 0)
print(count * fee)


n = int(input())
mas = list(map(int, input().split()))
(x, f) = map(int, input().split())
res = 0
for i in range(n):
	q = mas[i]
	if q > x:
		(a, b) = (q - x, x + f)
		(e, r) = (a // b, a % b)
		if r > 0:
			e += 1
		res += e * f
print(res)


import math
n = int(input())
pa = map(int, input().split())
(rem, fee) = map(int, input().split())
count = 0
for wallet in pa:
	count += math.ceil((wallet - rem) / (rem + fee))
print(count * fee)


import math
N = int(input())
Koshs = [int(x) for x in input().split()]
(x, f) = map(int, input().split())
count = 0
for money in Koshs:
	if money > x:
		count += math.ceil((money - x) / (x + f)) * f
print(count)


import math
n = int(input())
z = [int(x) for x in input().split(' ')]
(x, f) = [int(x) for x in input().split(' ')]
z = list(map(lambda a: a - x, z))
z = list(filter(lambda a: a > 0, z))
ans = 0
for c in z:
	ans += math.ceil(c / (x + f))
print(ans * f)