There are $n$ emotes in very popular digital collectible card game (the game is pretty famous so we won't say its name). The $i$-th emote increases the opponent's happiness by $a_i$ units (we all know that emotes in this game are used to make opponents happy).

You have time to use some emotes only $m$ times. You are allowed to use any emotion once, more than once, or not use it at all. The only restriction is that you cannot use the same emote more than $k$ times in a row (otherwise the opponent will think that you're trolling him).

Note that two emotes $i$ and $j$ ($i \ne j$) such that $a_i = a_j$ are considered different.

You have to make your opponent as happy as possible. Find the maximum possible opponent's happiness.


-----Input-----

The first line of the input contains three integers $n, m$ and $k$ ($2 \le n \le 2 \cdot 10^5$, $1 \le k \le m \le 2 \cdot 10^9$) — the number of emotes, the number of times you can use emotes and the maximum number of times you may use the same emote in a row.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is value of the happiness of the $i$-th emote.


-----Output-----

Print one integer — the maximum opponent's happiness if you use emotes in a way satisfying the problem statement.


-----Examples-----
Input
6 9 2
1 3 3 7 4 2

Output
54

Input
3 1000000000 1
1000000000 987654321 1000000000

Output
1000000000000000000



-----Note-----

In the first example you may use emotes in the following sequence: $4, 4, 5, 4, 4, 5, 4, 4, 5$.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics

Greedy algorithms


Solutions:
def main():
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().split()))
	m1 = max(A)
	A.pop(A.index(m1))
	m2 = max(A)
	l = m // k
	sum1 = m1 * m
	sum1 -= m // (k + 1) * (m1 - m2)
	print(sum1)
main()


inp = lambda : map(int, input().split())
(n, m, k) = inp()
a = list(inp())
a.sort()
tmp = a[-1] * k + a[-2]
res = m // (k + 1) * tmp
res += a[-1] * (m % (k + 1))
print(res)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
f = a[-1]
s = a[-2]
ans = m // (k + 1) * (f * k + s) + m % (k + 1) * f
print(ans)


(n, m, k) = [int(x) for x in input().split()]
a = [int(i) for i in input().split()]
m1 = max(a)
a.remove(m1)
m2 = max(a)
total = (k * m1 + m2) * (m // (k + 1)) + m % (k + 1) * m1
print(total)


(n, m, k) = [*map(int, input().split())]
a = [*map(int, input().split())]
a.sort()
a = a[::-1]
ans = 0
if k == 1:
	if m % 2 == 0:
		print(m // 2 * a[0] + m // 2 * a[1])
	else:
		print((m // 2 + 1) * a[0] + m // 2 * a[1])
elif k == 2:
	su = m // (k + 1)
	count = m - su
	ans += count * a[0]
	ans += su * a[1]
	print(ans)
elif m % k == 0:
	su = m // k - 1
	count = m - su
	ans += count * a[0]
	ans += su * a[1]
	print(ans)
else:
	su = m // (k + 1)
	count = m - su
	ans += count * a[0]
	ans += su * a[1]
	print(ans)


import heapq
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
(x, y) = heapq.nlargest(2, a)
print(m // (k + 1) * y + (m - m // (k + 1)) * x)


import sys, datetime
(n, m, k) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
arr.sort(reverse=True)
temp = [arr[0], arr[1]]
ans = arr[0] * m - arr[0] * (m // (k + 1)) + arr[1] * (m // (k + 1))
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def quad(tup):
	(x, y) = tup
	if x > y:
		return -1
	if y > x:
		return 1
	else:
		return 0

def solve():
	(n, m, k) = sep()
	ar = lis()
	ar.sort()
	ma1 = ar[-1]
	ma2 = ar[-2]
	t1 = m // (k + 1)
	t2 = m % (k + 1)
	print(t1 * k * ma1 + t1 * ma2 + t2 * ma1)
solve()


import math
inarr = lambda : map(int, input().split())
for _ in range(1):
	(n, m, k) = map(int, input().split())
	a = list(inarr())
	a.sort()
	a.reverse()
	print(m // (k + 1) * 1 * (a[0] * 1 * k + a[1]) + m % (k + 1) * 1 * a[0])


(n, m, k) = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
if m <= k:
	print(m * A[0])
else:
	x = k * A[0] + A[1]
	tot = x * (m // (k + 1))
	rem = m % (k + 1)
	tot += rem * A[0]
	print(tot)


l = input().split(' ')
n = int(l[0])
m = int(l[1])
k = int(l[2])
a = list(map(int, input().split()))
a.sort()
v1 = m // (k + 1)
value = v1 * (int(a[n - 1]) * k + a[n - 2])
value = value + (m - v1 * (k + 1)) * a[n - 1]
print(value)


(n, m, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
arr.sort()
count = m // (k + 1)
s = arr[-1] * count * k
s += arr[-2] * count
s += arr[-1] * (m % (k + 1))
print(s)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
y = max(l)
l.remove(y)
z = max(l)
a = m % (k + 1)
if a == 0:
	h = m // (k + 1)
	print((y * k + z) * h)
else:
	r = m // (k + 1)
	l = (k + 1) * r
	o = (m - l) * z
	print((y * k + z) * r + m % (k + 1) * y)


line1 = input()
n = int(line1.split(' ')[0])
m = int(line1.split(' ')[1])
k = int(line1.split(' ')[2])
line2 = input()
a = line2.split(' ')
arr = []
for i in a:
	arr.append(int(i))
arr.sort()
arr = arr[-2::1]
res = 0
p = m // (k + 1)
res += (k * arr[1] + arr[0]) * p
res += m % (k + 1) * arr[1]
print(res)


(n, m, k) = map(int, input().split())
H = [i for i in map(int, input().split())]
first = max(H)
del H[H.index(first)]
second = max(H)
Happiness = 0
d = k
dis = m // (k + 1)
lis = m % (k + 1)
Happiness += dis * k * first + lis * first + dis * second
print(Happiness)


def inputSeperator(inputStr):
	return list(map(int, inputStr.split(' ')))
temp = inputSeperator(input())
n = temp[0]
m = temp[1]
k = temp[2]
count = 0
numbers = inputSeperator(input())
numbers = sorted(numbers)
firstMax = numbers[len(numbers) - 1]
secondMax = numbers[len(numbers) - 2]
count += m // (k + 1) * k * firstMax
count += m // (k + 1) * secondMax
count += m % (k + 1) * firstMax
print(count)


(n, m, k) = map(int, input().split())
emotes = list(map(int, input().split()))
emotes.sort(reverse=True)
res = emotes[0] * (m // (k + 1)) * k + emotes[1] * (m // (k + 1)) + m % (k + 1) * emotes[0]
print(res)


(t, m, k) = map(int, input().split())
l = list(map(int, input().split()))
max1 = max(l)
l.remove(max1)
max2 = max(l)
ans = 0
a = m // (k + 1)
ans = a * (k * max1 + max2)
b = m % (k + 1)
ans += b * max1
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
max1 = a[n - 1]
max2 = a[n - 2]
amount = 0
cnt = m // (k + 1)
amount += (k * max1 + max2) * cnt
amount += m % (k + 1) * max1
print(amount)


cnt = lambda s, i: s.count(i)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
(n, m, k) = f()
l = il()
c = 0
s = 0
l.sort()
sm = m // (k + 1) * (l[-1] * k + l[-2])
if m % (k + 1) != 0:
	print(sm + m % (k + 1) * l[-1])
else:
	print(sm)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
first = l[-1]
second = l[-2]
x = m // (k + 1)
y = m % (k + 1)
ans = x * k * first + y * first + x * second
print(int(ans))


TN = 1

def solution():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	mx = max(a)
	if a[0] == a[1]:
		print(m * a[0])
	elif k >= m:
		print(m * a[0])
	else:
		print((k * a[0] + a[1]) * (m // (k + 1)) + m % (k + 1) * a[0])
while TN != 0:
	solution()
	TN -= 1


(n, m, k) = list(map(int, input().split()))
a = list(sorted(map(int, input().split())))
x = a[-1]
y = a[-2]
b = int(m / (k + 1))
print(b * y + (m - b) * x)


value = list(map(int, input().split()))
(n, m, k) = (value[0], value[1], value[2])
a = list(map(int, input().split()))
val = max(a)
a.remove(val)
sec = max(a)
print(val * (m // (k + 1) * k + m % (k + 1)) + sec * (m // (k + 1)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
maximum1 = max(a)
a.remove(maximum1)
maximum2 = max(a)
print(m // (k + 1) * (maximum1 * k + maximum2) + m % (k + 1) * maximum1)


(n, m, k) = map(int, input().split())
ais = list(map(int, input().split()))
(fst, snd, *_) = sorted(ais, key=lambda n: -n)
tot = m // (k + 1) * snd + (m - m // (k + 1)) * fst
print(tot)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, m, k) = I()
l = I()
l.sort()
if n == 1:
	print(l[0])
	exit()
a = l[-1]
b = l[-2]
if m <= k:
	print(m * a)
	exit()
x = a * k + b
print(x * (m // (k + 1)) + a * (m % (k + 1)))


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))[:n]
x = max(l)
l.remove(x)
y = max(l)
ans = 0
a = m // (k + 1)
b = m % (k + 1)
ans = a * (k * x + y) + b * x
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
ans = m // (k + 1) * (k * a[0] + a[1])
ans += m % (k + 1) * a[0]
print(ans)


(n, m, k) = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
p = p[-2:]
print(m // (k + 1) * (p[0] + p[1] * k) + m % (k + 1) * p[1])


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
x = m // (k + 1)
z = m - x
print(l[n - 1] * z + l[n - 2] * x)


(n, m, k) = map(int, input().split())
a = list(sorted(map(int, input().split())))
print(m // (k + 1) * (a[-1] * k + a[-2]) + m % (k + 1) * a[-1])


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
largest = max(arr)
arr.remove(largest)
second_largest = max(arr)
if largest == second_largest:
	print(str(largest * m))
else:
	happiness = 0
	segment_val = largest * k + second_largest
	happiness += segment_val * int(m / (k + 1))
	happiness += largest * (m % (k + 1))
	print(happiness)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
c = max(a)
j = a.index(c)
max1 = -1
for i in range(n):
	if i != j:
		max1 = max(max1, a[i])
print((c * k + max1) * (m // (k + 1)) + c * (m % (k + 1)))


params = [int(i) for i in input().split()]
entrada = [int(i) for i in input().split()]
primeiro = int(entrada[0])
segundo = -1
for i in range(1, params[0]):
	if entrada[i] >= primeiro:
		segundo = primeiro
		primeiro = int(entrada[i])
	elif entrada[i] > segundo:
		segundo = int(entrada[i])
	pass
value = int(params[1] / (params[2] + 1))
diff = params[1] - int(value * (params[2] + 1))
saida = int(value * (params[2] * primeiro)) + int(value * segundo) + int(diff * primeiro)
print('{:d}'.format(saida))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
m1 = 0
m2 = 0
for c in a:
	if c >= m1:
		(m1, m2) = (c, m1)
	elif c >= m2:
		m2 = c
ans = m // (k + 1) * (m1 * k + m2) + m % (k + 1) * m1
print(ans)


(x, y, z) = list(map(int, input().split(' ')))
n = list(map(int, input().split(' ')))
k = max(n)
if n.count(k) > 1:
	print(k * y)
else:
	n.remove(k)
	r = max(n)
	print(y // (z + 1) * (k * z + r) + y % (z + 1) * k)


(n, m, k) = map(int, input().split())
lst = list(map(int, input().split()))
if n == 1:
	print(lst[0] * min(m, k))
else:
	mx1 = max(lst)
	a = lst.index(mx1)
	lst[a] = 0
	mx2 = max(lst)
	a = lst.index(mx2)
	lst[a] = 0
	(d, md) = (m // (k + 1), m % (k + 1))
	res = d * k * mx1 + d * mx2 + md * mx1
	print(res)


(noe, will_do, can_do) = [int(x) for x in input().split()]
satisfy = sorted([int(x) for x in input().split()], reverse=True)
(a, b) = (satisfy[0], satisfy[1])
if can_do >= will_do or a == b:
	print(a * will_do)
else:
	times = will_do // (can_do + 1)
	ans = a * times * can_do + b * times
	rest = will_do % (can_do + 1)
	ans += rest * a
	print(ans)


(n, m, k) = map(int, input().split())
list = sorted(map(int, input().split()))
calculator1 = list[-1] * k + list[-2]
calculator2 = m // (k + 1)
answer = calculator1 * calculator2 + list[-1] * (m % (k + 1))
print(answer)


import sys, os
from math import sqrt
from collections import defaultdict
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, m, k) = map(int, input().split())
emotes = list(map(int, input().split()))
emotes.sort(reverse=True)
Mx = emotes[0]
mn = emotes[1]
ans = 0
ans = m // (k + 1) * Mx * k
ans += m // (k + 1) * mn
ans += m % (k + 1) * Mx
print(ans)


(n, m, k) = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
ans = m // (k + 1) * (a[-1] * k + a[-2])
ans += m % (k + 1) * a[-1]
print(ans)


def main():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	mx = a[-1]
	mx2 = a[-2]
	if m % (k + 1) == 0:
		print(m // (k + 1) * (k * mx + mx2))
	else:
		print((m - m % (k + 1)) // (k + 1) * (k * mx + mx2) + m % (k + 1) * mx)
	return
main()


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
c = max(a)
b = a.index(max(a))
a[b] = 0
d = max(a)
print(m // (k + 1) * (k * c + d) + m % (k + 1) * c)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
a1 = arr[-1]
a2 = arr[-2]
div = k * (m // (k + 1)) + m % (k + 1)
ans = a1 * div + a2 * (m - div)
print(ans)


(n, m, k) = list(map(int, input().split()))
hap = list(map(int, input().split()))
max1 = max(hap)
hap.remove(max1)
max2 = max(hap)
print(max1 * (m - m // (k + 1)) + max2 * (m // (k + 1)))


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
if k == m:
	print(max(a) * k)
else:
	oneSet = a[0] * k + a[1]
	print(oneSet * (m // (k + 1)) + a[0] * (m % (k + 1)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
low = 1
high = m
while low <= high:
	mid = low + high >> 1
	baapu = (k + 1) * mid
	if baapu == m:
		break
	elif baapu > m:
		high = mid - 1
	else:
		low = mid + 1
a.sort(reverse=True)
has = a[0]
ro = a[1]
if (k + 1) * mid > m:
	mid -= 1
count = k * mid * has + mid * ro + has * (m - (k + 1) * mid)
print(count)


(n, m, k) = map(int, input().split())
numberList = list(map(int, input().split()))
count = flag = 0
max1 = max(numberList)
numberList.remove(max1)
max2 = max(numberList)
if m % (k + 1) != 0:
	adjFactor = m % (k + 1)
	m -= adjFactor
	flag = 1
temp = m // (k + 1)
count += max1 * (k * temp)
count += max2 * (m - k * temp)
if flag == 1:
	while adjFactor:
		if adjFactor <= k:
			count += max1 * adjFactor
			adjFactor -= adjFactor
		else:
			count += max1 * k
			adjFactor -= k
		if adjFactor:
			count += max2
			adjFactor -= 1
print(count)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
s = 0
if n == 1:
	print(a[0] * k)
else:
	x = m // (k + 1)
	r = a[0] * x * k + a[1] * x
	r += a[0] * (m - x * (k + 1))
	print(r)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
m1 = max(a)
a.remove(m1)
m2 = max(a)
print(m1 * (m // (k + 1)) * k + m2 * (m // (k + 1)) + m1 * (m - m // (k + 1) * (k + 1)))


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
k1 = a[-1]
k2 = a[-2]
x = m // (k + 1)
ans = k2 * x + (m - x) * k1
print(ans)


(n, m, k) = tuple(map(int, input().split()))
A = list(map(int, input().split()))
m1 = max(A)
count = A.count(m1)
if count == 1:
	A = set(A)
	A.remove(m1)
	m2 = max(A)
else:
	m2 = m1
x = m // (k + 1)
ans = x * (k * m1 + m2)
m %= k + 1
ans += m * m1
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
r = max(a)
a[a.index(r)] = 0
s = max(a)
qut = m // (k + 1)
rem = m % (k + 1)
ans = qut * r * k + qut * s + rem * r
print(ans)


(N, M, K) = map(int, input().split())
l = list(map(int, input().split()))
_Max = 0
for i in l:
	_Max = max(_Max, i)
c = 0
for i in l:
	if i == _Max:
		c += 1
if c >= 2:
	print(_Max * M)
else:
	sec_M = max(list(filter(lambda x: x < _Max, l)))
	print(M // (K + 1) * sec_M + (M - M // (K + 1)) * _Max)


from sys import stdin, stdout

def inp():
	return stdin.readline()

def minp():
	return map(int, stdin.readline().rstrip().split())

def linp():
	return list(minp())

def main():
	(n, m, k) = minp()
	lst = linp()
	lst.sort()
	fm = lst[-1]
	sm = lst[-2]
	s = fm * k
	s += sm
	d = m // (k + 1)
	if m <= k:
		print(fm * k)
	else:
		s = s * d
		d = m % (k + 1)
		s += fm * d
		print(s)
main()


(n, m, k) = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)[:2]
print((a[0] * k + a[1]) * (m // (k + 1)) + a[0] * (m % (k + 1)))


l1 = input()
l = l1.split()
n = int(l[0])
m = int(l[1])
k = int(l[2])
l2 = input()
l3 = l2.split()
a = [int(item) for item in l3]
b = sorted(a)
c = b.pop()
d = b.pop()
sum1 = 0
p = m / (k + 1)
q = int(p)
r = m - q * (k + 1)
sum1 = c * q * k + d * q + c * r
print(sum1)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
temp = m // (k + 1)
print(temp * arr[-2] + (m - temp) * arr[-1])


(n, m, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
p = l[-1]
q = l[-2]
r = m // (k + 1)
one = p * k + q
total = one * r + m % (k + 1) * p
print(total)


(n, m, k) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
q = m // (k + 1)
r = m % (k + 1)
L.sort()
a = L[-1]
b = L[-2]
print(a * (k * q + r) + b * q)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
largest = max(arr)
arr.remove(largest)
largest2 = max(arr)
unit = k * largest + largest2
no = m // (k + 1)
hap = no * unit + m % (k + 1) * largest
print(hap)


(n, a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
c = a // (b + 1)
print(c * l[-2] + l[-1] * (a - c))


(N, M, K) = [int(n) for n in input().split()]
a = sorted([int(n) for n in input().split()])
syou = M // (K + 1)
amari = M % (K + 1)
ans = syou * (K * a[-1] + a[-2]) + amari * a[-1]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
s = m // (k + 1)
mod = m % (k + 1)
print(s * (a[0] * k + a[1]) + mod * a[0])


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
z = max(a)
a.pop(a.index(z))
dz = max(a)
print(m // (k + 1) * (z * k + dz) + z * (m % (k + 1)))


(n, m, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
a = max(arr)
if arr.count(a) > 1:
	b = a
else:
	arr = sorted(arr)
	b = arr[n - 2]
u = 0
l = m // (k + 1)
u += l * (k * a + b)
w = m % (k + 1)
u += w * a
print(u)


def main():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [(x, i) for (i, x) in enumerate(a)]
	a.sort(reverse=True)
	(t, r) = (m % (k + 1), m // (k + 1))
	ret = r * (k * a[0][0] + a[1][0]) + t * a[0][0]
	print(ret)
main()


(n, m, k) = map(int, input().split())
mas = sorted(list(map(int, input().split())), reverse=True)
(z, s) = (0, 0)
z = m // (k + 1)
s = mas[1] * z + mas[0] * (m - z)
print(s)


(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ma = max(a)
ans = 0
b = a.count(ma)
a.sort(reverse=True)
for i in a:
	if i != ma:
		sec = i
		break
if b > 1 or m == k:
	ans = ma * m
else:
	x = m // (k + 1)
	p = (ma * k + sec) * x
	ans = p
	if x != 0:
		q = ma * (m % ((k + 1) * x))
		ans += q
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
temp = m // (k + 1)
ans = 0
ans = temp * (a[-1] * k + a[-2])
ans += m % (k + 1) * a[-1]
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
b = l[-2]
c = k + 1
p = a * k + b
b = p * (m // c)
b += m % c * l[-1]
print(b)


import math
arr1 = [int(i) for i in input().split()]
arr2 = [int(i) for i in input().split()]
bigger = 0
big = 0
for i in arr2:
	if i > bigger:
		(bigger, big) = (i, bigger)
	elif i > big:
		big = i
arr1[2] += 1
bigs = math.floor(arr1[1] / arr1[2])
happy = big * bigs + bigger * (arr1[1] - bigs)
print(happy)


(n, m, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
f = a[-1]
s = a[-2]
grp = m // (k + 1)
left = m % (k + 1)
ans = grp * (k * f + s) + left * f
print(ans)


(n, m, k) = map(int, input().split())
e = list(map(int, input().split()))
ma = max(e)
e.remove(ma)
mu = max(e)
q = m // (k + 1)
p = m % (k + 1)
res = (k * ma + mu) * q + ma * p
print(res)


(n, m, k) = map(int, input().strip().split())
L = list(map(int, input().strip().split()))
L.sort(reverse=True)
max1 = L[0]
max2 = L[1]
g = m // (k + 1)
ans = max1 * g * k + max2 * g + max1 * (m % (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
x = max(arr)
i = arr.index(x)
del arr[i]
y = max(arr)
Z = x * k + y
Z = Z * (m // (k + 1))
if m % (k + 1) != 0:
	c = m - m // (k + 1) * (k + 1)
	Z += x * c
if x == y or m == k:
	print(x * m)
else:
	print(Z)


(lens, maxop, rowop) = [int(x) for x in input().split()]
(a, b) = sorted([int(x) for x in input().split()], reverse=True)[:2]
times = maxop // (rowop + 1)
answer = times * a * rowop + times * b + (maxop - times * (rowop + 1)) * a
print(answer)


(n, m, k) = input().split()
N = int(n)
M = int(m)
K = int(k)
vet = input().split()
valor = list()
maior = 0
segmaior = 0
cont = 0
felicidade = 0
for i in vet:
	valor.append(int(i))
valor.sort()
valor.reverse()
maior = valor[0]
segmaior = valor[1]
felicidade = (segmaior + K * maior) * int(M / (K + 1)) + maior * (M % (K + 1))
print(felicidade)


(n, m, k) = list(map(int, input().split()))
A = sorted([int(x) for x in input().split()])
m1 = A[-1]
m2 = A[-2]
print(m // (k + 1) * (m1 * k + m2) + m % (k + 1) * m1)


(n, m, k) = map(int, input().split())
array = list(map(int, input().split()))
array.sort()
x = array[-1]
y = array[-2]
t = 0
p = 0
s = 0
s += m // (k + 1) * (k * x + y)
s += m % (k + 1) * x
print(s)


import sys
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
GOSA = 1.0 / 10 ** 10
MOD = 10 ** 9 + 7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z') + 1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def DP(N, M, first):
	return [[first] * M for n in range(N)]

def DP3(N, M, L, first):
	return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe

def dump(*args):
	names = {id(v): k for (k, v) in currentframe().f_back.f_locals.items()}
	print(', '.join((names.get(id(arg), '???') + ' => ' + repr(arg) for arg in args)), file=sys.stderr)

def local_input():
	from pcm.utils import set_stdin
	import sys
	from pathlib import Path
	parentdir = Path(os.path.dirname(__file__)).parent
	inputfile = parentdir.joinpath('test/sample-1.in')
	if len(sys.argv) == 1:
		set_stdin(inputfile)

def solve():
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	dump(A)
	a = A[0]
	b = A[1]
	res = 0
	res += (a * k + b) * (m // (k + 1))
	res += a * (m % (k + 1))
	print(res)
	return 0
try:
	local_input()
except:
	pass
solve()


(n, m, k) = [int(x) for x in input().split()]
(b, a) = sorted([int(x) for x in input().split()])[-2:]
total = 0
y = m // (k + 1)
total += (a * k + b) * y
rem = m % (k + 1)
total += rem * a
print(total)


i = lambda : map(int, input().split())
(n, m, k) = i()
a = sorted(i())[::-1]
print(m // (k + 1) * (k * a[0] + a[1]) + m % (k + 1) * a[0])


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
m1 = a[0]
m2 = a[1]
print((k * m1 + m2) * (m // (k + 1)) + m1 * (m % (k + 1)))


(n, m, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr.sort(reverse=True)
joy = 0
(q, r) = divmod(m, k + 1)
joy += arr[0] * q * k + arr[1] * q + arr[0] * r
print(joy)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
if k == m:
	print(k * a[-1])
else:
	print(m // (k + 1) * k * a[-1] + m // (k + 1) * a[-2] + a[-1] * (m % (m // (k + 1) * (k + 1))))


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
f = arr[-1]
s = arr[-2]
ans = m // (k + 1) * (f * k + s) + m % (k + 1) * f
print(ans)


inputs = [int(x) for x in input().split(' ')]
n = inputs[0]
m = inputs[1]
k = inputs[2]
nums = [int(x) for x in input().split(' ')]
nums.sort()
x = int(m / (k + 1))
y = m - x
ans = x * nums[-2] + y * nums[-1]
print(ans)


(n, m, k) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
max = max(a)
max_count = 0
for elem in a:
	if elem == max:
		max_count += 1
	if max_count == 2:
		break
if max_count > 1:
	print(m * max)
else:
	max_but_one = -1
	for elem in a:
		if elem > max_but_one and elem < max:
			max_but_one = elem
	ans = int(m / (k + 1)) * (max * k + max_but_one)
	ans += m % (k + 1) * max
	print(ans)


from math import ceil
(n, k, m) = map(int, input().split())
list1 = [int(n) for n in input().split()]
max1 = max(list1)
list1.remove(max1)
max2 = max(list1)
res = int(k / (m + 1)) * (m * max1 + max2) + k % (m + 1) * max1
print(int(res))


def main():
	(n, m, k) = [int(v) for v in input().split()]
	data = [int(v) for v in input().split()]
	data.sort(reverse=True)
	if len(data) == 1:
		print(data[0])
	else:
		v = m // (k + 1)
		av = v
		vv = data[0] * k * v + data[0] * (m % (k + 1))
		avv = data[1] * av
		print(vv + avv)
main()


firstline = input().split()
n = int(firstline[0])
m = int(firstline[1])
k = int(firstline[2])
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a.sort(key=None, reverse=True)
len = int(m / (k + 1))
ren = int(m % (k + 1))
print(len * k * a[0] + len * a[1] + ren * a[0])


(n, m, k) = map(int, input().split(' '))
li = list(map(int, input().split(' ')))
li.sort(reverse=True)
mx = li[0]
mx2 = li[1]
ans = int((mx * k + mx2) * int(m / (k + 1)))
ans = ans + int(m % (k + 1) * mx)
print(ans)


(n, m, k) = map(int, input().split())
v = list(map(int, input().split()))
m1 = 0
m2 = 0
for i in range(n):
	if v[i] >= m1:
		m2 = m1
		m1 = v[i]
	else:
		m2 = max(m2, v[i])
print(m // (k + 1) * m2 + (m - m // (k + 1)) * m1)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
first = a[0]
second = a[1]
s = 0
T = k + 1
q = m // T
r = m % T
s = q * (k * first + second)
s += min(k, r) * first
s += max(r - k, 0) * second
print(s)


arr_str = input().split()
(n, m, k) = (int(arr_str[0]), int(arr_str[1]), int(arr_str[2]))
arr_str = input().split()
arr = [int(x) for x in arr_str]
first_max = 0
second_max = -1
for el in arr:
	if el > first_max:
		second_max = first_max
		first_max = el
	elif first_max >= el > second_max:
		second_max = el
unit = m // (k + 1)
rest = m % (k + 1)
total_happiness = unit * (first_max * k + second_max) + rest * first_max
print(total_happiness)


(n, m, k) = map(int, input().split())
lis = list(map(int, input().split()))
lis.sort()
print(lis[n - 1] * (m - m // (k + 1)) + lis[n - 2] * (m // (k + 1)))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(n, m, k) = LI()
	a = sorted(LI())
	t = a[-1]
	u = a[-2]
	c = m // (k + 1)
	return u * c + t * (m - c)
print(main())


(n, m, l) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = max(a)
a.remove(b)
c = max(a)
s = b * l + c
d = m // (l + 1)
sum = s * d
if m % (l + 1) != 0:
	print(sum + b * (m % (l + 1)))
else:
	print(sum)


(n, m, k) = (int(t) for t in input().split(' '))
a = [int(t) for t in input().split(' ')]
maxi = 0
for i in range(1, len(a)):
	if a[i] > a[maxi]:
		maxi = i
submaxi = 0 if maxi != 0 else 1
for i in range(submaxi, len(a)):
	if i != maxi and a[i] > a[submaxi]:
		submaxi = i
print((a[maxi] * k + a[submaxi]) * (m // (k + 1)) + a[maxi] * (m % (k + 1)))


import sys
from collections import defaultdict
import heapq
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
(n, m, k) = intInp()
arr = intInp()
arr.sort(reverse=True)
rep = m // (k + 1)
ans = (arr[0] * k + arr[1]) * rep + m % (k + 1) * arr[0]
print(ans)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
(n, m, k) = mi()
l = lm()
l.sort()
l1 = l[-1]
l2 = l[-2]
ma = l1 * m
bads = m // (k + 1)
ma = ma - bads * (l1 - l2)
print(ma)


def max_happiness(n, m, k, a):
	a = sorted(a, key=lambda x: -1 * x)
	return int(m / (k + 1)) * (k * a[0] + a[1]) + m % (k + 1) * a[0]
(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
print(max_happiness(n, m, k, a))


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
(n, m, k) = mi()
a = li()
mx = max(a)
mi = a.index(mx)
mx2 = max(a[:mi] + a[mi + 1:])
rep = m // (k + 1)
ans = rep * (k * mx + mx2)
rem = m % (k + 1)
ans += rem * mx
print(ans)


(n, m, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
if m > k:
	ou = a[n - 1] * k + a[n - 2]
	c = m // (k + 1)
	ou = ou * c
	ou += m % (k + 1) * a[n - 1]
else:
	ou = a[n - 1] * k
print(ou)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a = sorted(a)
mx = a[n - 1]
mx2 = a[n - 2]
ans = m // (k + 1) * mx2 + (m - m // (k + 1)) * mx
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
	print(k * l[0])
else:
	l.sort(reverse=True)
	i = m // (k + 1)
	print(l[1] * i + l[0] * (m - i))


[n, m, k] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = max(a)
a.remove(b)
b2 = max(a)
r = (b2 + k * b) * (m // (k + 1)) + m % (k + 1) * b
print(r)


X = list(map(int, input().split()))
Emotes = sorted(list(map(int, input().split())), reverse=True)
print(Emotes[0] * X[1] if Emotes[0] == Emotes[1] else Emotes[0] * (X[1] - X[1] // (X[2] + 1)) + Emotes[1] * (X[1] // (X[2] + 1)))


from math import floor

def main():
	[n, m, k] = list(map(int, input().split(' ')))
	ar = list(map(int, input().split(' ')))
	c = floor(m / (k + 1))
	r = m % (k + 1)
	a = max(ar)
	ar.pop(ar.index(a))
	b = max(ar)
	maxHappiness = c * (a * k + b) + r * a
	print(maxHappiness)
main()


(n, m, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
(x, y) = sorted(l)[-2:]
print(y * (m // (k + 1)) * k + x * (m // (k + 1)) + y * (m % (k + 1)))


(n, m, k) = input().split(' ')
(n, m, k) = (int(n), int(m), int(k))
arr = list(map(int, input().split(' ')))
arr.sort()
x = arr[-1]
y = arr[-2]
ans = int(m / (k + 1)) * (x * k + y) + m % (k + 1) * x
print(ans)


(n, m, k) = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
x = k * (m // (k + 1))
y = m // (k + 1)
if x + y < m:
	x += m - (x + y)
print(v[n - 1] * x + v[n - 2] * y)


(n, m, k) = map(int, input().split())
list_1 = [int(i) for i in input().split()]
max_1 = max(list_1)
list_1.remove(max_1)
max_2 = max(list_1)
times = m // (k + 1)
remain = m % (k + 1)
times *= max_1 * k + max_2
remain *= max_1
print(times + remain)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, m, k) = int_array()
a = sorted(int_array())
x = a.pop()
y = a.pop()
c = m // (k + 1)
ans = c * (k * x + y)
ans += m % (k + 1) * x
print(ans)


(n, m, k) = map(int, input().split())
all_ints = sorted(map(int, input().split()), reverse=True)
(n1, n2) = (all_ints[0], all_ints[1])
(q, r) = divmod(m, k + 1)
l1 = n1 * k + n2
l2 = n1 * r
s = q * l1 + l2
print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = m % (k + 1)
if s == 0:
	x = k * a[-1] + a[-2]
	print(x * (m // (k + 1)))
elif s == m - 1:
	x = k * a[-1] + a[-2]
	print(x * (m // (k + 1) + 1) - a[-2])
else:
	x = k * a[-1] + a[-2]
	print(x * (m // (k + 1)) + a[-1] * s)


(n, m, k) = [int(x) for x in input().split()]
l = list(map(int, input().split()))
l.sort()
t = m // (k + 1)
r = m - t
print(r * l[-1] + t * l[-2])


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
max1 = 0
max2 = 0
for i in a:
	if i > max1:
		max2 = max1
		max1 = i
	elif i > max2:
		max2 = i
ans = (max1 * k + max2) * (m // (k + 1)) + max1 * (m % (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
max = a[0]
second = a[1]
chunk = k * max + second
times = m // (k + 1)
ans = times * chunk
m %= k + 1
ans += m * max
print(ans)


entrada = input()
p = [int(x) for x in entrada.split()]
(n, m, k) = (p[0], p[1], p[2])
a = input()
a = [int(x) for x in a.split()]
a.sort()
sesion = k * a[-1] + a[-2]
ans = int(m / (k + 1)) * sesion + m % (k + 1) * a[-1]
print(ans)


(n, m, k) = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
ans = m // (k + 1) * v[-2] + m // (k + 1) * k * v[-1] + m % (k + 1) * v[-1]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if k >= m:
	print(a[0] * m)
else:
	print(m // (k + 1) * (a[0] * k + a[1]) + m % (k + 1) * a[0])


user_input = input().split(' ')
n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])
row = input().split(' ')
list = []
for a in row:
	list.append(int(a))
list.sort()
p = int(m / (k + 1))
a = int(p * k * list[n - 1])
b = int(p * list[n - 2])
c = int(m % (k + 1))
c *= list[n - 1]
print(a + b + c)


def rainy(N, K, L):
	total = 0
	fBiggest = max(L)
	L.remove(fBiggest)
	sBiggest = max(L)
	if K == 0:
		return 0
	while N > 0:
		numTimes = int(N / (K + 1))
		total += numTimes * (K * fBiggest + sBiggest)
		N -= numTimes * (K + 1)
		if N < K + 1:
			break
	total += N * fBiggest
	return total
RAW_VARS = input().split(' ')
S = int(RAW_VARS[0])
N = int(RAW_VARS[1])
K = int(RAW_VARS[2])
RAW_LIST = input().split(' ')
L = []
for i in range(S):
	L.append(int(RAW_LIST[i]))
print(rainy(N, K, L))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
Max = max(a)
a.remove(Max)
SecMax = max(a)
useSecMax = m // (k + 1)
print(useSecMax * SecMax + (m - useSecMax) * Max)


(n, m, k) = map(int, input().split())
s = input().split()
z = []
for i in range(0, n):
	z.append(int(s[i]))
z = sorted(z)
print(m // (k + 1) * (z[-1] * k + z[-2]) + m % (k + 1) * z[-1])


def ans(arr):
	arr.sort(reverse=True)
	x = m // (k + 1)
	cnt = arr[0] * k + arr[1]
	cnt *= x
	x = m - x * (k + 1)
	if x <= k:
		cnt += arr[0] * x
	return cnt
nmk = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
(n, m, k) = (nmk[0], nmk[1], nmk[2])
print(ans(a))


(n, m, k) = map(int, input().split())
a = input().split()
a = [int(i) for i in a]
m1 = max(a[:2])
m2 = min(a[:2])
for i in range(2, n):
	if a[i] > m1:
		m2 = m1
		m1 = a[i]
	elif a[i] > m2:
		m2 = a[i]
loop = m // (k + 1)
last = m % (k + 1)
ans = (m1 * k + m2) * loop + m1 * last
print(ans)


from sys import stdin
(n, m, k) = map(int, stdin.readline().split())
arr = sorted(list(map(int, stdin.readline().split())), reverse=True)
a = arr[0]
b = arr[1]
x = m // (k + 1)
y = m - (k + 1) * x
print(a * (k * x + y) + b * x)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
big1 = 0
index = -1
for i in range(0, n):
	if a[i] > big1:
		big1 = a[i]
		index = i
big2 = 0
for j in range(0, n):
	if a[j] > big2 and j != index:
		big2 = a[j]
val = big1 * k + big2
final = val * (m // (k + 1)) + big1 * (m % (k + 1))
print(final)


(n, m, k) = (int(i) for i in input().strip().split())
d = [int(i) for i in input().strip().split()]
d.sort()
d = d[::-1]
u = m // (k + 1)
r = m % (k + 1)
print(u * k * d[0] + r * d[0] + u * d[1])


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
tp = m // (k + 1)
print((m - tp) * a[0] + tp * a[1])


import sys, collections, math, itertools, random, bisect
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
(n, m, k) = get_ints()
arr = get_array()
arr.sort()
mx1 = arr[-1]
mx2 = arr[-2]
print(mx1 * (m - m // (k + 1)) + m // (k + 1) * mx2)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
qmax1 = a[0]
qmax2 = a[1]
if qmax1 < qmax2:
	(qmax1, qmax2) = (qmax2, qmax1)
for i in range(2, n):
	if a[i] >= qmax1:
		(qmax1, qmax2) = (a[i], qmax1)
	elif a[i] > qmax2:
		qmax2 = a[i]
s = qmax1 - qmax2
ssum = m * qmax1
howmany = m // (k + 1)
print(ssum - s * howmany)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	(n, m, k) = get_ints()
	arr = get_array()
	arr.sort()
	if m <= k:
		print(arr[-1] * m)
		return
	x = arr[-1] * k + arr[-2]
	p = m // (k + 1)
	ans = x * p
	p = m % (k + 1)
	ans += arr[-1] * p
	print(ans)
main()


(n, m, k) = map(int, input().split())
a = [int(o) for o in input().split()]
a = sorted(a)
a = a[::-1]
lol = m // (k + 1)
uu = m % (k + 1)
try:
	rt = k * a[0] + a[1]
	print(lol * rt + uu * a[0])
except:
	print(k * a[0])


user_input = input().split(' ')
n = int(user_input[0])
m = int(user_input[1])
k = int(user_input[2])
row = input().split(' ')
list = []
for a in row:
	list.append(int(a))
list.sort()
first = list[n - 1]
second = list[n - 2]
result = 0
count = int(m / (k + 1)) * k
count += m % (k + 1)
result += count * first
result += (m - count) * second
print(result)


s = input().split(' ')
n = int(s[0])
m = int(s[1])
k = int(s[2])
s = input()
a = [int(i) for i in s.split(' ')]
a.sort(reverse=True)
combo = k + 1
rem = m % combo
cnt = int(m // combo)
r = a[0] * cnt * k + a[1] * cnt + a[0] * rem
print(r)


import heapq
(n, m, k) = map(int, input().split())
a = map(int, input().split())
(max1, max2) = heapq.nlargest(2, a)
whole = m // (k + 1)
whole_happy = whole * (k * max1 + max2)
part = m - (k + 1) * whole
part_happy = part * max1
print(whole_happy + part_happy)


def solve(a, n, m, k):
	if n == 1:
		return min(m, k) * a[-1]
	a.sort()
	if k >= m:
		return m * a[-1]
	num = m // (k + 1) * (k * a[-1] + a[-2]) + m % (k + 1) * a[-1]
	return num
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(a, n, m, k))


(n, m, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort(reverse=True)
a = m // (k + 1)
count = l[0] * a * k + l[1] * a
b = m % (k + 1)
count += b * l[0]
print(count)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
iters = m // (k + 1)
remaining = m % (k + 1)
print(iters * (arr[0] * k + arr[1]) + remaining * arr[0])


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = 1

def solve():
	rem = m % (k + 1)
	ans = l[0] * rem
	mul = m // (k + 1)
	ans += mul * (k * l[0] + l[1])
	return ans
for _ in range(t):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	print(solve())


a = input().strip().split()
a[0] = int(a[0])
a[1] = int(a[1])
a[2] = int(a[2])
b = input().strip().split()
max_1 = 0
max_2 = 0
for i in range(len(b)):
	if int(b[i]) > max_1:
		max_2 = max_1
		max_1 = int(b[i])
	elif int(b[i]) == max_1:
		max_2 = max_1
	elif int(b[i]) < max_1 and int(b[i]) > max_2:
		max_2 = int(b[i])
result = 0
m = a[1]
k = a[2]
tuples = m // (k + 1)
result += tuples * (k * max_1 + max_2)
remainder = m % (k + 1)
result += remainder * max_1
print(result)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
a.sort()
q = a[n - 1]
w = a[n - 2]
r = k * q + w
u = m // (k + 1)
c = u * r + q * (m - u * (k + 1))
print(c)


(n, m, k) = map(int, input().split())
s = [int(x) for x in input().split()]
mx1 = -1
mx2 = -1
for i in range(0, len(s)):
	if s[i] >= mx1:
		mx2 = mx1
		mx1 = s[i]
	elif s[i] >= mx2:
		mx2 = s[i]
ans = m // (k + 1) * (k * mx1 + mx2)
ans += m % (k + 1) * mx1
print(ans)


(n, tot, ma) = map(int, input().split())
li = list(map(int, input().split()))
li = sorted(li)
li = li[::-1]
c1 = 0
d = 0
k = ma + 1
x = tot // k
h = tot % k
print(x * ma * li[0] + x * li[1] + h * li[0])


import sys
from itertools import islice

def get_two_max(lst):
	max_1 = max(islice(lst, 2))
	max_2 = min(islice(lst, 2))
	for i in islice(lst, 2, len(lst)):
		if i > max_2:
			if i > max_1:
				max_2 = max_1
				max_1 = i
			else:
				max_2 = i
	return (max_1, max_2)

def get_max_emotions(vals, n, m, k):
	(max_1, max_2) = get_two_max(vals)
	alpha = m // (k + 1)
	rest_vals = m % (k + 1)
	return alpha * (max_1 * k + max_2) + rest_vals * max_1
if len(sys.argv) > 1 and sys.argv[1] == 'test':
	tests = [[(6, 9, 2), [1, 3, 3, 7, 4, 2], 54], [(3, 1000000000, 1), [1000000000, 987654321, 1000000000], 1000000000000000000], [(4, 3, 3), [1, 2, 3, 4], 12], [(4, 3, 2), [1, 2, 3, 4], 11], [(4, 3, 1), [1, 2, 3, 4], 11], [(4, 10, 3), [1, 2, 3, 4], 38]]
	for t in tests:
		print(get_max_emotions(t[1], *t[0]), t[2])
else:
	first_line = input()
	(n, m, k) = map(int, first_line.split())
	second_line = input()
	l = list(map(int, second_line.split()))
	print(get_max_emotions(l, n, m, k))


def read_input():
	s1 = input()
	s2 = input()
	(n, e, m) = [int(i) for i in s1.split()]
	a = [int(i) for i in s2.split()]
	return (n, e, m, a)

def find_max(a):
	b = sorted(a, reverse=True)
	return (b[1], b[0])

def problem_b(n, e, m, a):
	(sm, fm) = find_max(a)
	if e % (m + 1) == 0:
		print(e // (m + 1) * (fm * m + sm))
	else:
		num_times = e // (m + 1)
		remaining = e - num_times * (m + 1)
		print(num_times * (fm * m + sm) + remaining * fm)
(n, e, m, a) = read_input()
problem_b(n, e, m, a)


def getIntList(lst):
	assert type(lst) is list
	rep = []
	for i in lst:
		rep.append(int(i))
	return rep
(n, m, k) = getIntList(input().split(' '))
a = getIntList(input().split(' '))
a.sort()
minus = a[-1] - a[-2]
ans = a[-1] * m - minus * (m // (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
x = max(a)
a[a.index(x)] = -1
y = max(a)
result = (k * x + y) * (m // (k + 1)) + m % (k + 1) * x
print(result)


import sys
from math import gcd

def unique(lst):
	return dict(((o, o) for o in lst)).values()

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self, _map=str):
		return list(map(_map, sys.stdin.readline().split()))

	def next_int(self):
		return int(self.next())

	def solve(self):
		(n, m, k) = self.next_line(int)
		x = sorted(self.next_line(int))
		t1 = m // (k + 1) * k + m % (k + 1)
		t2 = m - t1
		print(t1 * x[-1] + t2 * x[-2])
Main().solve()


(n, m, k) = map(int, input().split())
L = sorted(map(int, input().split()))
(ma1, ma2) = (L[n - 1], L[n - 2])
(p, q) = divmod(m, k + 1)
print(p * k * ma1 + p * ma2 + q * ma1)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
print(m * a[len(a) - 1] - m // (k + 1) * a[len(a) - 1] + m // (k + 1) * a[len(a) - 2])


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = l[-1]
b = l[-2]
if k >= m:
	print(m * a)
elif m % (k + 1) == 0:
	c = m // (k + 1)
	d = k * a + b
	print(c * d)
else:
	e = m % (k + 1)
	c = m // (k + 1)
	d = k * a + b
	print(c * d + e * a)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import *
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def chk(x, y):
	print(x, '=', y)

def ncr(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]
(n, m, k) = numIN()
l = list(numIN())
l.sort()
cnt = l.count(l[-1])
if cnt >= 2:
	print(l[-1] * m)
else:
	(q, r) = divmod(m, k + 1)
	ans = (l[-1] * k + l[-2]) * q + l[-1] * r
	print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
m1 = l[0]
m2 = l[1]
term = m // (k + 1)
rem = m % (k + 1)
ans = k * m1 * term + m2 * term + rem * m1
print(ans)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
Max1 = max(a)
a.remove(Max1)
Max2 = max(a)
if Max1 is not Max2:
	complete = m // (k + 1)
	happiness = Max1 * (complete * (k + 1) - complete)
	happiness += Max2 * complete
	happiness += m % (k + 1) * Max1
	print(happiness)
else:
	print(m * Max1)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
a1 = a[0]
a2 = a[1]
z = 0
ans += m // (k + 1) * (k * a1 + a2)
ans += m % (k + 1) * a1
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
(a1, a2) = (a[-1], a[-2])
both_count = m // (k + 1)
total = (k * a1 + a2) * both_count
rem = m - both_count * (k + 1)
a1_count = min(rem, k)
total += a1_count * a1
print(total)


x = input().split()
n = int(x[0])
m = int(x[1])
k = int(x[2])
y = input().split()
y = list(map(int, y))
maxh = max(y)
yy = y.copy()
del yy[yy.index(maxh)]
if max(yy) == maxh:
	print(m * maxh)
else:
	maxhh = max(yy)
	turns = m // (k + 1)
	laffa = k * maxh
	rest = m - (k * turns + turns)
	total = turns * laffa + turns * maxhh + maxh * rest
	print(total)


def go():
	(n, m, k) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	a.sort(reverse=True)
	m1 = a[0]
	m2 = a[1]
	x = m // (k + 1)
	return m1 * x * k + m2 * x + m % (k + 1) * m1
print(go())


def smile_emote(n, times, row, a):
	a = sorted(a)
	if row >= times:
		return a[-1] * times
	else:
		q = times // (row + 1)
		remain = times - q * (row + 1)
		oneq = a[-1] * row + a[-2]
		return oneq * q + a[-1] * remain
(n, times, row) = list(map(int, input().split()))
a = list(map(int, input().split()))
print(smile_emote(n, times, row, a))


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m // (k + 1)
h = k * a * l[n - 1] + a * l[n - 2]
b = m % (k + 1)
h += b * l[n - 1]
print(h)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
_max = 0
_sMax = 0
for i in range(n):
	if a[i] >= _max:
		_sMax = _max
		_max = a[i]
	elif a[i] > _sMax:
		_sMax = a[i]
u = k * _max + _sMax
c = m // (k + 1)
ans = u * c + (m - c * (k + 1)) * _max
print(ans)


(n, m, k) = tuple(map(int, input().split()))
(f1, f2) = (0, 0)
numbers = list(map(int, input().split()))
for number in numbers:
	if number >= f1:
		f2 = f1
		f1 = number
	elif number >= f2:
		f2 = number
iteration = m // (k + 1)
reminder = m - (k + 1) * iteration
print((k * f1 + f2) * iteration + reminder * f1)


(n, m, k) = [int(p) for p in input().split()]
arr = [int(p) for p in input().split()]
arr.sort(reverse=True)
(a1, a2) = (arr[0], arr[1])
if m % (k + 1) == 0:
	b = m // (k + 1)
	print(b * (k * a1 + a2))
else:
	b = m // (k + 1)
	print(b * (k * a1 + a2) + a1 * (m % (k + 1)))


from sys import stdin
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m, k) = mapin()
a = listin()
a.sort()
ans = 0
bit = k * a[-1] + a[-2]
ans += bit * (m // (k + 1))
ans += a[-1] * (m % (k + 1))
print(ans)


(n, m, k) = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
inp = input().split(' ')
ar = []
for i in inp:
	ar.append(int(i))
ar.sort()
s = 0
val = int(m / (k + 1))
if m % (k + 1) == 0:
	s = ar[-1] * k * val + ar[-2] * val
else:
	s = ar[-1] * k * val + ar[-1] * (m % (k + 1)) + ar[-2] * val
print(s)


(n, m, k) = map(int, input().split())
l = [int(i) for i in input().split()]
l1 = sorted(l, reverse=True)
st = l1[0]
st1 = l1[1]
z = k + 1
z1 = m // z
z2 = m % z
use = k * z1 * st + z1 * st1 + z2 * st
print(use)


(n, m, k) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort(reverse=True)
ans = 0
l = m // (k + 1)
ans += A[0] * k * l
ans += A[1] * l
ans += A[0] * (m % (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
num1 = a[0]
num2 = a[1]
count = 0
res = 0
res += m // (k + 1) * num2
res += (m - m // (k + 1)) * num1
print(res)


(n, m, k) = map(int, input().split())
a = [0] * n
a = list(map(int, input().split()))
max = a[0]
smax = 0
pos = -1
for i in range(n):
	if a[i] >= max:
		max = a[i]
		pos = i
for i in range(n):
	if pos != i and a[i] > smax:
		smax = a[i]
if k >= m or smax == max:
	print(m * max)
else:
	sum = k * max + smax
	sum = sum * (m // (k + 1)) + max * (m % (k + 1))
	print(sum)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
L = l[-1]
sl = l[-2]
if L == sl:
	print(L * m)
else:
	ans = m // (k + 1) * (L * k + sl)
	ans += m % (k + 1) * L
	print(ans)


def cin():
	return map(int, input().split())
import collections
import time
(n, m, k) = cin()
a = list(cin())
a.sort(reverse=True)
ans = a[0] * (m // (k + 1)) * k + a[1] * (m // (k + 1)) + a[0] * (m % (k + 1))
print(ans)


R = lambda : map(int, input().split())
(n, m, k) = R()
(x, y) = sorted(R())[-2:]
print(m % (k + 1) * y + m // (k + 1) * (y * k + x))


import heapq
(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
(max1, max2) = heapq.nlargest(2, arr)
if k >= m:
	print(m * max1)
else:
	ans1 = m // (k + 1) * (k * max1 + max2)
	ans2 = m % (k + 1) * max1
	print(ans1 + ans2)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
a1 = a[-1]
a2 = a[-2]
x1 = m // (k + 1)
x2 = m % (k + 1)
print((a1 * k + a2) * x1 + a1 * x2)


(n, m, k) = [int(x) for x in input().split()]
emojy = [int(x) for x in input().split()]
emojy.sort(reverse=True)
print(m // (k + 1) * (emojy[0] * k + emojy[1]) + m % (k + 1) * emojy[0])


q = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
n = q[0]
m = q[1]
k = q[2]
mx1 = max(a)
a.remove(mx1)
mx2 = max(a)
a1 = mx1 * k + mx2
z = m // (k + 1)
ans = a1 * z
z2 = m % (k + 1)
ans = ans + mx1 * z2
print(int(ans))


a = input()
(n, m, k) = (int(a.split()[0]), int(a.split()[1]), int(a.split()[2]))
A = input()
l = list(map(int, A.split()))
s = 0
l.sort()
n = len(l)
ma = l[n - 1]
ma1 = l[n - 2]
s = s + (m - m // (k + 1)) * ma
s = s + m // (k + 1) * ma1
print(s)


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
emotes_list = input().split()
emotes_list = list(map(int, emotes_list))
sortedemo = sorted(emotes_list, reverse=True)
max1 = sortedemo[0]
max2 = sortedemo[1]
print(m % (k + 1) * max1 + (max1 * k + max2) * (m // (k + 1)))


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
ar = input().split()
for i in range(0, n):
	ar[i] = int(ar[i])
mx = max(ar)
count = 0
mx2 = 0
for i in range(0, n):
	if ar[i] == mx:
		count = count + 1
	if ar[i] > mx2 and mx != ar[i]:
		mx2 = ar[i]
	if count >= 2 and ar[i] > mx2:
		mx2 = ar[i]
g = m // (k + 1)
print(g * mx * k + g * mx2 + mx * (m % (k + 1)))


(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
m1 = 0
m2 = 0
ind = 0
for i in range(n):
	if l1[i] > m1:
		m1 = l1[i]
		ind = i
for i in range(n):
	if l1[i] > m2 and i != ind:
		m2 = l1[i]
if k > m:
	ans = m * m1
	print(ans)
else:
	ans = 0
	temp = k * m1 + m2
	ans = m // (k + 1) * temp
	ans = ans + m % (k + 1) * m1
	print(ans)


__author__ = 'NIORLYS'
[n, m, k] = list(map(int, input().split()))
happ_value = list(map(int, input().split()))
happ_value.sort()
m1 = happ_value[-1]
m2 = happ_value[-2]
i = k + 1
print(m // (k + 1) * m1 * k + m // (k + 1) * m2 + m % (k + 1) * m1)


(n, m, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = k * (m // (k + 1)) * l[0] + m // (k + 1) * l[1]
if k * (m // (k + 1)) + m // (k + 1) != m:
	ans = ans + (m - (k * (m // (k + 1)) + m // (k + 1))) * l[0]
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
sec = 0
maxi = 0
for i in range(n):
	if l[i] > maxi:
		sec = maxi
		maxi = l[i]
	elif l[i] > sec:
		sec = l[i]
t = m // (k + 1)
man = (k * maxi + sec) * t + (m - (k + 1) * t) * maxi
print(man)


(n, m, k) = map(int, input().split())
lis = list(map(int, input().split()))
x = max(lis)
lis[lis.index(x)] = -1
y = max(lis)
print((k * x + y) * (m // (k + 1)) + m % (k + 1) * x)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
q = a[0]
w = a[1]
print(w * (m // (k + 1)) + q * (m - m // (k + 1)))


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
if a[0] > a[1]:
	m1 = a[0]
	m2 = a[1]
else:
	m1 = a[1]
	m2 = a[0]
if n > 2:
	for i in range(2, n):
		if a[i] > m1:
			m2 = m1
			m1 = a[i]
		elif a[i] > m2:
			m2 = a[i]
h = m // (k + 1) * (m1 * k + m2) + m % (k + 1) * m1
print(h)


(n, m, k) = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums.sort()
(x, y) = (nums[-1], nums[-2])
print(m // (k + 1) * (x * k + y) + m % (k + 1) * x)


(n, m, k) = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)
mi = m // (k + 1)
print(l[0] * k * mi + l[1] * mi + l[0] * (m % (k + 1)))


class Emotes:

	def __init__(self):
		(self.n_num, self.m_num, self.k_num) = map(int, input().split(' '))
		self.num_list = list(map(int, input().split(' ')))

	def solve(self):
		self.num_list.sort(reverse=True)
		(num_a, num_b) = (self.num_list[0], self.num_list[1])
		ans = 0
		add_num = num_a * self.k_num + num_b
		ans += add_num * (self.m_num // (self.k_num + 1))
		ans += num_a * (self.m_num % (self.k_num + 1))
		print(ans)
que = Emotes()
que.solve()


(n, m, k) = map(int, input().split())
ar = list(map(int, input().split()))
ar.sort(reverse=True)
l = ar[0]
sl = ar[1]
ans = m // (k + 1) * (k * l + sl) + m % (k + 1) * l
print(ans)


def emotes():
	emotes = list(map(int, input().split()))
	values = list(map(int, input().split()))
	maximum = max(values)
	table = {maximum: 0}
	index = 0
	for i in range(len(values)):
		if values[i] in table:
			table[values[i]] += 1
			index = i
			if table[values[i]] == 2:
				return maximum * emotes[1]
	values.pop(index)
	maximum_2 = max(values)
	temp = int(emotes[1] / (emotes[2] + 1))
	first = temp * (maximum * emotes[2])
	second = temp * maximum_2
	output = first + second
	emotes[1] = emotes[1] - temp * (emotes[2] + 1)
	if emotes[1] > 0:
		output += emotes[1] * maximum
	return output
A = emotes()
print(A)


a = input()
a = a + ' '
c = input()
c = c + ' '
b = []
d = []
v = ''
for i in a:
	if i == ' ':
		b.append(int(v))
		v = ''
		continue
	v = v + i
m = b[1]
k = b[2]
u = ''
for i in c:
	if i == ' ':
		d.append(int(u))
		u = ''
		continue
	u = u + i
d.sort()
big = d[-1]
big2 = d[-2]
ex = 0
if m == k:
	ex = big * m
if m > k:
	x = m // (k + 1)
	kalan = m % (k + 1)
	ex = x * (big * k + big2) + kalan * big
print(ex)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
max1 = a[0]
max2 = a[0]
a.sort()
a = a[::-1]
max1 = a[0]
max2 = a[1]
p = m // (k + 1)
result = k * max1 * p + p * max2
p = m % (k + 1)
result += p * max1
print(result)


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
a = [int(x) for x in input().split()]
a.sort()
x = a[n - 1]
y = a[n - 2]
mul = m // (k + 1)
mm = m % (k + 1)
ans = (x * k + y) * mul + x * mm
print(ans)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
elem1 = max(a)
a.pop(a.index(elem1))
elem2 = max(a)
res = m // (k + 1) * (k * elem1 + elem2) + m % (k + 1) * elem1
print(res)


nmk = [int(x) for x in input().split()]
values = [int(x) for x in input().split()]

def emotes(lista1, lista2):
	m = lista1[1]
	k = lista1[2]
	index_max = lista2.index(max(lista2))
	max1 = max(lista2)
	del lista2[index_max]
	max2 = max(lista2)
	return int(m / (k + 1)) * (max1 * k + max2) + m % (k + 1) * max1
print(emotes(nmk, values))


(n, m, k) = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
a = li[-1]
b = li[-2]
count = 0
f = m // (k + 1)
count += a * k * f + b * f
j = m - f * (k + 1)
count += a * j
print(count)


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
mx = a[-1]
mxx = a[-2]
kol = 0
fullmx = mx * k * (m // (k + 1))
ostmx = mx * (m % (k + 1))
fullmxx = mxx * (m // (k + 1))
print(fullmx + ostmx + fullmxx)


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
array = list(map(int, input().split()))
maxm1 = 0
maxm2 = 0
i = 0
while i < len(array):
	if array[i] >= maxm1:
		maxm2 = maxm1
		maxm1 = array[i]
	elif array[i] > maxm2:
		maxm2 = array[i]
	i += 1
if k < m:
	div = m // (k + 1)
	rem = m % (k + 1)
	ans = div * (k * maxm1 + maxm2) + rem * maxm1
else:
	ans = m * maxm1
print(ans)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
(n, m, k) = ei()
emotes = ai()
emotes.sort()
m1 = emotes[-1]
m2 = emotes[-2]
x = m // (k + 1) * (m1 * k + m2) + m % (k + 1) * m1
op(x)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = l[0]
b = l[1]
c = m // (k + 1)
q = m % (k + 1)
d = a * c * k + b * c
d = d + q * l[0]
print(d)


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	(x, y) = (a[-1], a[-2])
	r = 0
	q = m // (k + 1)
	r += (k * x + y) * q + m % (k + 1) * x
	print(r)


n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
print(n[1] // (n[2] + 1) * a[-2] + (n[1] - n[1] // (n[2] + 1)) * a[-1])


(n, m, k) = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
sumd = 0
ans = 0
l = m // (k + 1)
c = m % (k + 1)
ans = k * li[n - 1] + li[n - 2]
if m >= k:
	ans = l * ans + c * li[n - 1]
else:
	ans = ans * max(li)
print(ans)


(n, m, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
if n == 1:
	print(l[0])
else:
	l.sort()
	cnt = 0
	x = k + 1
	y = m // x
	z = m % x
	q = l[-1] * k + l[-2]
	print(q * y + l[-1] * z)


import sys
from functools import reduce
from math import sqrt, floor

def eprint(*args, **kwargs):
	if not __debug__:
		print(*args, file=sys.stderr, **kwargs)
eprint('Local\n')
for t in range(int(input()) if not __debug__ else 1):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	x = m // (k + 1)
	res = (x * k + m % (k + 1)) * arr[n - 1]
	res += x * arr[n - 2]
	print(res)


def emotions(lst, m, k):
	return m // (k + 1) * (lst[-1] * k + lst[-2]) + m % (k + 1) * lst[-1]
(n, M, K) = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]
print(emotions(sorted(a), M, K))


import heapq
(_, m, k) = list(map(int, input().split()))
(a, b) = heapq.nlargest(2, list(map(int, input().split())))
print(a * m - m // (k + 1) * (a - b))


from math import ceil
(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
x = a[0]
y = a[1]
ans = m // (k + 1) * (x * k + y) + m % (k + 1) * x
print(ans)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
f = m // (k + 1)
s = f * a[1] + a[0] * (m - f)
print(s)


a = input().split()
b = input().split()
a = list(map(int, a))
b = list(map(int, b))
m = a[1]
k = a[2]
M = max(b)
b.remove(M)
n = max(b)
l = m // (k + 1)
mod = m % (k + 1)
sum = l * (k * M + n) + mod * M
print(int(sum))


(n, m, k) = map(int, input().split())
emotes = [int(bruhh) for bruhh in input().split()]
emotes.sort()
cycles = m // (k + 1)
leftover = m % (k + 1)
res = 0
res += k * emotes[-1] * cycles
res += emotes[-2] * cycles
res += emotes[-1] * leftover
print(res)


from sys import stdin
(n, m, k) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
arr.sort()
a = m // (k + 1)
maxhappy = (arr[-1] * k + arr[-2]) * a
maxhappy += arr[-1] * (m % (k + 1))
print(maxhappy)


(a, b, c) = list(map(int, input().split()))
n = list(map(int, input().split()))
jam = max(n)
n.remove(max(n))
lam = max(n)
if b == c:
	print(b * jam)
else:
	kam = c * jam
	kam += lam
	ham = c + 1
	gh = b // ham
	kam = kam * gh
	sam = b - ham * gh
	kam += jam * sam
	print(kam)


(n, m, k) = input().split()
(n, m, k) = (int(n), int(m), int(k))
v = [int(x) for x in input().split()]
v.sort(reverse=True)
a = v[0]
b = v[1]
if m % (k + 1) == 0:
	print(int(m / (k + 1)) * (k * a + b))
else:
	print(int(m / (k + 1)) * (k * a + b) + m % (k + 1) * a)


import io, sys, atexit, os
import math as ma
from decimal import Decimal as dec
from itertools import permutations

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

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def solve():
	t = 1
	for it in range(t):
		(n, m, k) = num()
		a = li()
		a.sort()
		hh = a[n - 1]
		h2 = a[n - 2]
		op = m // (k + 1)
		po = m % (k + 1)
		ans = op * k * hh + op * h2 + po * hh
		print(ans)

def __starting_point():
	solve()
__starting_point()


temp = input().split(' ')
k = int(temp[1])
m = int(temp[2])
temp = input().split(' ')
arr = list(map(lambda x: int(x), temp))
arr.sort()
max1 = arr[-1]
max2 = arr[-2]
t = k // (m + 1)
r = k % (m + 1)
print(r * max1 + t * (m * max1 + max2))


(n, o, k) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a = sorted(a)
m = a[n - 1]
m_1 = a[n - 2]
s = m * k + m_1
sum = int(o / (k + 1)) * s
o %= k + 1
sum += o * m
print(sum)


(n, m, k) = map(int, input().split())
a = [int(num) for num in input().split(' ', n - 1)]
a.sort()
res = 0
full_pers = m // (k + 1)
res = k * a[n - 1] * full_pers + full_pers * a[n - 2]
res += m % (k + 1) * a[n - 1]
print(int(res))


(n, m, k) = map(int, input().split())
c = list(map(int, input().split()))
l1 = m // (k + 1)
l2 = m % (k + 1)
d = sorted(c)
mx = d[-1]
mx2 = d[-2]
r = l1 * (k * mx + mx2) + l2 * mx
print(r)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
(x, y) = (a[0], a[1])
div = m // (k + 1)
mod = m % (k + 1)
print(div * (k * x + y) + mod * x)


from sys import stdin

def read_lines(sep=' ', input_type=None):
	_lines = stdin.readlines()
	cast = input_type is not None
	lines = []
	for line in _lines:
		line = line[:-1].split(sep)
		if cast:
			line = [input_type(x) for x in line]
		lines.append(line)
	return lines

def sequential_max_diff(seq):
	unlagged_seq = seq[:-1]
	lagged_seq = seq[1:]
	maxd = 0
	for pair in zip(unlagged_seq, lagged_seq):
		diff = abs(pair[0] - pair[1])
		if diff > maxd:
			maxd = diff
	return maxd

def main2():
	lines = read_lines(input_type=int)
	n = lines[0][0]
	heights = lines[1]
	_seq = heights
	_seq.sort()
	least = _seq[-1]
	elements = _seq
	min_pair = None
	for i in range(len(elements)):
		for j in range(len(elements)):
			if j == i:
				continue
			(a, b) = (elements[i], elements[j])
			seq = _seq.copy()
			seq.remove(a)
			seq.remove(b)
			res = max(sequential_max_diff([a] + seq + [b]), abs(a - b))
			if res < least:
				min_pair = (a, b)
				least = res
	seq = _seq.copy()
	seq.remove(min_pair[0])
	seq.remove(min_pair[1])
	out = list(map(str, [min_pair[0]] + seq + [min_pair[1]]))
	print(' '.join(out))

def main():
	lines = read_lines(input_type=int)
	(n, m, k) = lines[0]
	v = lines[1]
	max1 = max(v)
	max2 = 0
	max_appears = 0
	for ele in v:
		if ele == max1:
			max_appears += 1
			if max_appears == 2:
				print(max1 * m)
				return
	for ele in v:
		if ele != max1:
			if ele >= max2:
				max2 = ele
	block_size = k + 1
	num_of_blocks = m // block_size
	remainder = m % block_size
	value = num_of_blocks * (k * max1 + max2) + remainder * max1
	print(value)
main()


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
happy = 0
i = 0
happy = (a[0] * k + a[1]) * (m // (k + 1)) + a[0] * (m % (k + 1))
print(happy)


(n, m, k) = map(int, input().split(' '))
emotes = list(map(int, input().split(' ')))
maximum = max(emotes)
emotes.remove(maximum)
sec = max(emotes)
p = m // (k + 1)
z = m % (k + 1)
print((k * maximum + sec) * p + z * maximum)


import sys
lines = []
for line in sys.stdin:
	lines.append(line)
info = lines[0]
info = [int(i) for i in info.split()]
total = info[1]
max_sequence = info[2]
cost = lines[1]
cost = [int(i) for i in cost.split()]
max_cost = 0
second_cost = 0
for c in cost:
	if c > max_cost:
		second_cost = max_cost
		max_cost = c
	elif c > second_cost:
		second_cost = c
result = total * max_cost - total // (max_sequence + 1) * (max_cost - second_cost)
print(result)


import heapq
(n, m, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
(a, b) = heapq.nlargest(2, arr)
nb = m // (k + 1)
na = m - nb
h = na * a + nb * b
print(h)


(n, k, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
max = -1
max2 = -1
for i in a:
	if i > max:
		max2 = max
		max = i
	elif i > max2:
		max2 = i
times = k // (m + 1)
rem = k - times * (m + 1)
hap = times * (m * max + max2) + rem * max
print(hap)


(n, m, k) = map(int, input().split())
numList = list(map(int, input().split()))
numList.sort()
kCnt = 0
answer = 0
answer += (k * numList[-1] + numList[-2]) * (m // (k + 1))
answer += m % (k + 1) * numList[-1]
print(answer)


l = input().split()
n = int(l[0])
m = int(l[1])
k = int(l[2])
l = sorted(list(map(int, input().split())))
s = 0
d = m // (k + 1)
r = m % (k + 1)
s = s + d * k * l[-1]
s = s + d * l[-2]
s = s + r * l[-1]
print(s)


(n, m, k) = map(int, input().split())
a = sorted(map(int, input().split()))
ans = 0
x = m // (k + 1)
print((a[n - 1] * k + a[n - 2]) * x + m % (k + 1) * a[n - 1])


(n, m, k) = map(int, input().split())
cl = list(map(int, input().split()))
cl = sorted(cl)[::-1]
t = (m + 1) // (k + 1)
res = t * k * cl[0] + (t - 1) * cl[1]
m -= t * k + t - 1
if m != 0:
	res += cl[1]
	m -= 1
	res += m * cl[0]
print(res)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if m <= k:
	print(a[0] * m)
	exit()
t = m // (k + 1)
e = m % (k + 1)
ans = t * (k * a[0] + a[1])
ans += e * a[0]
print(ans)


(n, m, k) = map(int, input().split())
s = [int(x) for x in input().split()]
Max = max(s)
s.remove(Max)
Max_second = max(s)
cnt = 0
a = m // (k + 1)
print((m - a) * Max + a * Max_second)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, m, k) = get_int_list()
lst = get_int_list()
lst.sort()
m1 = lst[-1]
m2 = lst[-2]
print(m // (k + 1) * (k * m1 + m2) + (0 if m % (k + 1) == 0 else m % (k + 1) * m1))


(n, m, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
s = max(arr)
s1 = sorted(arr, reverse=True)[1]
i = 0
ans = 0
x = m // (k + 1)
ans += x * k * s + s1 * x
if x * (k + 1) < m:
	ans += (m - x * (k + 1)) * s
print(ans)


(n, m, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a.sort()
ans = a[-1] * (m - m // (k + 1)) + a[-2] * (m // (k + 1))
print(ans)


(n, m, k) = map(int, input().strip().split())
nums = [(int(i), index) for (index, i) in enumerate(input().strip().split(), 0)]
nums.sort(reverse=True)
(largest, selargest) = (nums[0][0], nums[1][0])
group_nums = m // (k + 1)
remains = m % (k + 1)
print(remains * largest + group_nums * selargest + group_nums * k * largest)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(sorted(a))
M = a[-1]
MM = a[-2]
hm = int(m / (k + 1))
r = m % (k + 1)
res = hm * (M * k + MM) + r * M
print(res)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
maxi = l[-1]
maxi2 = l[-2]
block = k * maxi + maxi2
print(block * (m // (k + 1)) + maxi * (m % (k + 1)))


import sys
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m1 = a[-1]
m2 = a[-2]
print(m1, m2, file=sys.stderr)
l = m // (k + 1)
ost = m % (k + 1)
print(l, file=sys.stderr)
print((m1 * k + m2) * l + m1 * ost)


(n, m, k) = map(int, input().split())
maxx = 0
maxx2 = 0
c = list(map(int, input().split()))
for i in range(0, n):
	if c[i] >= maxx:
		maxx2 = maxx
		maxx = c[i]
	if c[i] > maxx2 and c[i] < maxx:
		maxx2 = c[i]
print(m // (k + 1) * maxx2 + (m - m // (k + 1)) * maxx)


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
max = A[-1]
min = A[-2]
if m % (k + 1) == 0:
	t = m // (k + 1)
	an = t * k * max + t * min
	print(an)
else:
	t = m // (k + 1)
	an = t * k * max + t * min
	an += m % (k + 1) * max
	print(an)


import sys
inn = lambda : input().strip()
(N, M, K) = map(int, inn().split(' '))
emote = list(map(int, inn().split(' ')))
emote.sort(reverse=True)
(big1, big2) = (emote[0], emote[1])
count_big2 = M // (K + 1)
count_big1 = M - count_big2
print(big1 * count_big1 + big2 * count_big2)


(n, m, k) = map(int, input().split())
l = sorted(map(int, input().split()))
x = m // (k + 1)
y = m % (k + 1)
print(x * (k * l[-1] + l[-2]) + y * l[-1])


(a, b, c) = map(int, input().split())
d = list(map(int, input().split()))
r = max(d)
d.remove(r)
t = max(d)
k = b // (c + 1)
r1 = b % (c + 1)
print(r * r1 + r * c * k + k * t)


(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
rem = m % (k + 1)
coe = m // (k + 1)
combo = a[-1] * k + a[-2]
print(coe * combo + rem * a[-1])


from math import sqrt
import heapq

def main():
	(n, m, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	a = sorted(a)
	ans = (k * a[-1] + a[-2]) * (m // (k + 1)) + a[-1] * (m % (k + 1))
	print(ans)
main()


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
x = a[-1]
y = a[-2]
cnt = m // (k + 1)
b = m % (k + 1)
ans = cnt * (k * x + y) + b * x
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
a1 = max(l)
l.remove(a1)
a2 = max(l)
claw = (m - m // (k + 1)) * a1
claw += m // (k + 1) * a2
print(claw)


(n, m, k) = map(int, input().split())
lis = sorted([int(x) for x in input().split()])
l = lis[-1]
l2 = lis[-2]
print(l * (m - m // (k + 1)) + l2 * (m // (k + 1)))


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
M1 = A[0]
M2 = A[1]
print(M2 * (m // (k + 1)) + M1 * (m - m // (k + 1)))


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
max1 = a[0]
max2 = a[1]
blocks = m // (k + 1)
res = blocks * (k * max1 + max2) + (m - blocks * (k + 1)) * max1
print(res)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
t = m // (k + 1)
p = l[-2] * t
s = l[-1] * (m - t)
print(p + s)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
h = 0
m1 = a[-1]
m2 = a[-2]
if k >= m:
	h = a[-1] * k
else:
	units = m // (k + 1)
	h += a[-1] * k * units
	h += a[-2] * units
	h += a[-1] * (m - units * (k + 1))
print(h)


(n, m, k) = map(int, input().split())
s = [int(x) for x in input().split()]
el1 = max(s)
temp = 0
for i in range(0, len(s)):
	if s[i] == el1:
		temp = temp + 1
el2 = -1
for i in range(0, len(s)):
	if s[i] != el1:
		el2 = max(el2, s[i])
if temp > 1:
	el2 = el1
el = k * el1 + el2
rem = m % (k + 1)
qu = m // (k + 1)
ans = el * qu + rem * el1
print(ans)


l = input().split(' ')
n = int(l[0])
m = int(l[1])
k = int(l[2])
st = input().split(' ')
for i in range(n):
	st[i] = int(st[i])
st.sort(reverse=True)
koef = st[0] * k + st[1]
temp = 0
if m < k + 1:
	temp = st[0] * k
elif m % (k + 1) == 0:
	temp += koef * (m // (k + 1))
else:
	temp += koef * (m // (k + 1)) + st[0] * (m % (k + 1))
print(temp)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
res = 0
i = 0
j = 0
h = m // (k + 1)
res = h * (k * a[0] + a[1])
j = m % (k + 1)
res += j * a[0]
print(res)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = l[0]
b = l[1]
x = m // (k + 1)
ans = (a * k + b) * (m // (k + 1))
ans += a * (m % (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
cnt = m // (k + 1) * (x[-1] * k + x[-2])
if m % (k + 1) == 0:
	print(cnt)
else:
	print(cnt + m % (k + 1) * x[-1])


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
fm = max(l)
l.remove(fm)
sm = max(l)
ans = 0
if sm == fm:
	ans = fm * m
else:
	batch = fm * k + sm
	ans = batch * (m // (k + 1)) + m % (k + 1) * fm
print(ans)


line = input()
line = line.split()
n = int(line[0])
m = int(line[1])
k = int(line[2])
line = input()
line = line.split()
l = []
for i in range(n):
	l.append(int(line[i]))
h = 0
maxn = 0
nummax = 0
maxi = []
for i in range(n):
	if l[i] > maxn:
		maxn = l[i]
		nummax = 1
		maxi = []
		maxi.append(i)
	elif l[i] == maxn:
		nummax += 1
		maxi.append(i)
if nummax > 1:
	h = m * maxn
else:
	secmax = 0
	for i in range(n):
		if l[i] > secmax and l[i] < maxn:
			secmax = l[i]
	block = k * maxn + secmax
	h += m // (k + 1) * block
	h += m % (k + 1) * maxn
print(h)


(n, m, k) = map(int, input().split())
vls = list(map(int, input().split()))
vls.sort()
if vls[-1] == vls[-2]:
	print(max(vls) * m)
else:
	print((vls[-1] * k + vls[-2]) * (m // (k + 1)) + m % (k + 1) * vls[-1])


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, m, k) = mints()
a = list(mints())
a.sort()
b = a[-1]
c = a[-2]
z = m // (k + 1)
print((m - z) * b + c * z)


ls1 = list(map(int, input().split()))
ls = list(map(int, input().split()))
ls.sort()
n = ls1[0]
m = ls1[1]
k = ls1[2]
mx1 = ls[n - 1]
mx2 = ls[n - 2]
r1 = int(m / (k + 1))
r2 = int(m % (k + 1))
ans = r1 * mx2 + r1 * k * mx1 + r2 * mx1
print(ans)


(n, m, k) = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
p = m // (k + 1)
print(A[-1] * k * p + A[-2] * p + A[-1] * (m % (k + 1)))


import math
(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
sum = 0
sum += l[0] * k
sum += l[1]
ans = int(math.floor(m / (k + 1))) * sum
ans += m % (k + 1) * l[0]
print(int(ans))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
x = a[n - 1]
y = a[n - 2]
ma = k * x + y
res1 = m // (k + 1)
res2 = m % (k + 1)
res = ma * res1 + res2 * x
print(res)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
tmp1 = a[n - 1]
tmp2 = a[n - 2]
sum = tmp1 * k + tmp2
cnt = m // (k + 1)
ans = cnt * sum + m % (k + 1) * tmp1
print(ans)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
fr = max(arr)
sr = 0
pos = arr.index(fr)
for i in range(len(arr)):
	if arr[i] >= sr and i != pos:
		sr = arr[i]
print(m // (k + 1) * (k * fr + sr) + m % (k + 1) * fr)


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
for _ in range(1):
	(n, ln, k) = lst()
	a = lst()
	mx = smx = 0
	for v in a:
		if v >= mx:
			smx = mx
			mx = v
		elif v > smx:
			smx = v
	if ln <= k:
		print(mx * ln)
		continue
	each = ln // (1 + k)
	if each != 0:
		rem = ln % (each * (k + 1))
	print(each * (mx * k + smx) + rem * mx)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
a = m // (k + 1)
x = m % (k + 1)
a1 = a * k * l[-1] + l[-2] * a + x * l[-1]
print(a1)


li = input().split(' ')
n = int(li[0])
m = int(li[1])
k = int(li[2])
a = []
li = input().split(' ')
for i in range(n):
	a.append(int(li[i]))
a.sort()
ans = a[n - 1] * m
diff = a[n - 1] - a[n - 2]
ans -= diff * (m // (k + 1))
print(int(ans))


class Solution1117B:

	def __init__(self):
		self.m = 0
		self.k = 0
		self.happiness_values = []
		self.result = 0

	def parse_input(self):
		(_, self.m, self.k) = [int(i) for i in input().split(' ')]
		self.happiness_values = [int(i) for i in input().split(' ')]

	def solve(self):
		(largest, second_largest) = sorted(self.happiness_values, reverse=True)[:2]
		second_largest_uses = self.m // (self.k + 1)
		largest_uses = self.m - second_largest_uses
		self.result = largest_uses * largest + second_largest_uses * second_largest

	def get_result(self):
		return str(self.result)
solution = Solution1117B()
solution.parse_input()
solution.solve()
print(solution.get_result())


(n, m, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr.sort(reverse=True)
(a, b) = (arr[0], arr[1])
res = 0
(q, r) = divmod(m, k + 1)
res += q * k * a + q * b
res += r * a
print(res)


import math
(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
mx1 = l[-1]
mx2 = l[-2]
print(math.floor(m / (k + 1)) * (mx1 * k + mx2) + m % (k + 1) * mx1)


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
B = A[::-1]
S = 0
a = B[0]
b = B[1]
if k >= m:
	print(a * m)
else:
	D = k * a + b
	C = m % (k + 1)
	F = m // (k + 1)
	L = D * F + C * a
	print(L)


(n, m, k) = [int(s) for s in input().split()]
array = [int(s) for s in input().split()]
array = sorted(array, reverse=True)
first = array[0]
second = array[1]
res = (first * k + second) * (m // (k + 1)) + first * (m % (k + 1))
print(res)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
a1 = a[0]
a2 = a[1]
r = m // (k + 1)
r2 = a1 * k + a2
r3 = r * r2
r4 = m % (k + 1)
r3 += r4 * a1
print(r3)


_ = input()
(n, m, k) = _.split()
(n, m, k) = (int(n), int(m), int(k))
_ = input()
a = _.split()
a = [int(_) for _ in a]
_one = 0
_two = 0
for i in a:
	if _one <= i:
		_two = _one
		_one = i
	elif _two < i:
		_two = i
answer = (_one * k + _two) * (m // (k + 1)) + _one * (m % (k + 1))
print(answer)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
first_m = max(a[0], a[1])
second_m = min(a[0], a[1])
for i in range(2, n):
	if a[i] > first_m:
		second_m = first_m
		first_m = a[i]
	elif a[i] > second_m:
		second_m = a[i]
p = m // (k + 1)
print(first_m * k * p + second_m * p + first_m * (m - p * (k + 1)))


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
p = m // (k + 1)
q = m - p * (k + 1)
print(p * a[1] + (k * p + q) * a[0])


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
if n == 1:
	print(a[0] * k)
else:
	a.sort()
	a = a[::-1]
	s = 0
	count = 0
	q = a[0] * k + a[1]
	print(q * (m // (k + 1)) + a[0] * (m % (k + 1)))


def emote_problem():
	(xmax, imax, flag, sum) = (0, 0, 0, 0)
	(n, m, k) = input().split(' ')
	(n, m, k) = (int(n), int(m), int(k))
	input_list = input().split(' ')
	for (i, _) in enumerate(input_list):
		input_list[i] = int(input_list[i])
	for (i, _) in enumerate(input_list):
		if input_list[i] > xmax:
			imax = xmax
			xmax = input_list[i]
		elif input_list[i] > imax:
			imax = input_list[i]
	if xmax == imax:
		sum = m * xmax
	else:
		sum = int(m // (k + 1) * (k * xmax + imax) + m % (k + 1) * xmax)
	print(sum)
	return
emote_problem()


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
p = m // (k + 1)
x = m % (k + 1)
s = k * l[0] + l[1]
s = s * p
s = s + x * l[0]
print(s)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
isdebug = False
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
	isdebug = True
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if not isdebug:
	inId = 0
	outId = 0
if inId > 0:
	dprint('use input', inId)
	try:
		f = open('input' + str(inId) + '.txt', 'r')
		sys.stdin = f
	except Exception:
		dprint('invalid input file')
if outId > 0:
	dprint('use output', outId)
	try:
		f = open('stdout' + str(outId) + '.txt', 'w')
		sys.stdout = f
	except Exception:
		dprint('invalid output file')
	atexit.register(lambda : sys.stdout.close())
(N, M, K) = getIntList()
za = getIntList()
dprint(za)
za.sort()
a = za[-1]
b = za[-2]
r = 0
t = M // (K + 1)
r = t * (a * K + b)
r += M % (K + 1) * a
print(r)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

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

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	return ' '.join(list(map(str, a)))

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
(n, m, k) = isp()
a = iar()
a.sort()
n1 = a[n - 1]
n2 = a[n - 2]
s = 0
x = m % (k + 1)
y = m // (k + 1)
s += y * (a[n - 1] * k + a[n - 2])
s += x * a[n - 1]
print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if m <= k:
	print(max(a) * m)
else:
	st = a[-1] * k + a[-2]
	print(st * (m // (k + 1)) + a[-1] * (m % (k + 1)))


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
x = arr[-1]
y = arr[-2]
alpha = m // (k + 1)
ans = x * k * alpha + alpha * y
q = (k + 1) * alpha
if q < m:
	diff = m - q
	ans += x * diff
print(ans)


def f():
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	k.sort()
	t = l[1] // (l[2] + 1)
	r = l[1] % (l[2] + 1)
	ans = t * l[2] * k[-1] + t * k[-2] + r * k[-1]
	print(ans)
f()


(n, m, k) = map(int, input().split())
array = list(map(int, input().split()))
array.sort(reverse=True)
print(m // (k + 1) * (array[0] * k + array[1]) + m % (k + 1) * array[0])


def mi():
	return list(map(int, input().split()))
(n, m, k) = mi()
a = list(mi())
a.sort(reverse=True)
t = k + 1
nop = m // t
rem = m % t
print(nop * (k * a[0] + a[1]) + rem * a[0])


(a, b, c) = map(int, input().split())
z = sorted(list(map(int, input().split())))
q = b // (c + 1)
print(z[-2] * q + (b - q) * z[-1])


def second_largest(numbers):
	count = 0
	m1 = m2 = float('-inf')
	for x in numbers:
		count += 1
		if x > m2:
			if x >= m1:
				(m1, m2) = (x, m1)
			else:
				m2 = x
	return m2 if count >= 2 else None
(n, m, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
max1 = max(arr)
max2 = second_largest(arr)
if max1 == max2 or k >= m:
	print(m * max1)
else:
	div = m // (k + 1)
	rem = m % (k + 1)
	print(div * k * max1 + div * max2 + rem * max1)


(n, m, k) = map(int, input().split())
list1 = list(map(int, input().split()))
max = max(list1[0], list1[1])
secondmax = min(list1[0], list1[1])
for i in range(2, len(list1)):
	if list1[i] > max:
		secondmax = max
		max = list1[i]
	elif list1[i] > secondmax:
		secondmax = list1[i]
if max == secondmax:
	print(m * max)
else:
	a = m // (k + 1)
	print(a * secondmax + (m - a) * max)


(n, m1, k) = map(int, input().split())
a = [int(x) for x in input().split()]
m = max(a)
if a.count(m) > 1:
	sm = m
else:
	a = set(a) - {m}
	sm = max(a)
total = 0
temp = m1 // (k + 1)
total += (m1 - temp) * m
total += temp * sm
print(total)


s = input()
n = int(s.split(' ')[0])
m = int(s.split(' ')[1])
k = int(s.split(' ')[2])
d = input()
arr = []
for i in d.split(' '):
	arr.append(int(i))
arr.sort()
arr = arr[-2::1]
res = 0
p = m // (k + 1)
res += k * arr[1]
res += arr[0]
res *= p
e = m % (k + 1) * arr[1]
res += e
print(res)


(n, m, k) = map(int, input().split())
ln = list(map(int, input().split()))
mx = sorted(ln)[-1]
mn = sorted(ln)[-2]
print((mx * k + mn) * (m // (k + 1)) + m % (k + 1) * mx)


import sys
inp = sys.stdin.readline()[:-1].split(' ')
n = int(inp[0])
k = int(inp[1])
m = int(inp[2])
inp = sys.stdin.readline()[:-1].split(' ')
inp = [int(x) for x in inp]
inp.sort()
tmpM = m + 1
Emoj1 = k // tmpM
Emoj2 = k - Emoj1
ans = Emoj2 * inp[n - 1] + Emoj1 * inp[n - 2]
print(ans)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
su = 0
x = m // (k + 1)
y = m - x
su += arr[0] * y
su += arr[1] * x
print(su)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
mx1 = mx2 = 0
for i in range(n):
	if a[i] > mx1:
		mx2 = mx1
		mx1 = a[i]
	elif a[i] > mx2:
		mx2 = a[i]
t = m // (k + 1)
ans = t * k * mx1 + t * mx2
ans += m % (k + 1) * mx1
print(ans)


(n, m, k) = list(map(int, input().split()))
A = sorted(map(int, input().split()))
(a, b) = (A[-1], A[-2])
time = m // (k + 1)
ans = time * (a * k + b)
print(ans + a * (m % (k + 1)))


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
cases = m // (k + 1)
total = cases * (a[1] + k * a[0])
total += (m - cases * (k + 1)) * a[0]
print(total)


(n, m, k) = map(int, input().split())
numbers = list(map(int, input().split()))
(y, x) = sorted(numbers)[-2:]
val = m // (k + 1) * (x * k + y)
val2 = m % (k + 1) * x
print(val + val2)


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5:
	from math import gcd
else:
	from fractions import gcd
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def round(x):
	return int((x * 2 + 1) // 2)

def fermat(x, y, MOD):
	return x * pow(y, MOD - 2, MOD) % MOD

def lcm(x, y):
	return x * y // gcd(x, y)

def lcm_list(nums):
	return reduce(lcm, nums, 1)

def gcd_list(nums):
	return reduce(gcd, nums, nums[0])

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
(N, M, K) = MAP()
A = LIST()
A.sort(reverse=True)
ans = M // (K + 1) * (A[0] * K + A[1])
ans += M % (K + 1) * A[0]
print(ans)


(a, b, c) = map(int, input().split())
l = sorted(map(int, input().split()))
print((l[-1] * c + l[-2]) * (b // (c + 1)) + l[-1] * (b % (c + 1)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
ans = a[0] * (m - m // (k + 1)) + a[1] * (m // (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
arr = []
a.sort()
arr.append(a[-1])
arr.append(a[-2])
x = arr[0]
y = arr[-1]
print(m // (k + 1) * (x * k + y) + m % (k + 1) * x)


(g, m, k) = tuple(map(int, input().split()))
emotes = sorted(list(map(int, input().split())))[::-1]
print(m // (k + 1) * (emotes[0] * k + emotes[1]) + m % (k + 1) * emotes[0])


def two_max(max_arr, value):
	if max_arr[0] < value:
		max_arr[1] = max_arr[0]
		max_arr[0] = value
	elif max_arr[1] < value:
		max_arr[1] = value
	return max_arr

def emotes(n, m, k, arr):
	max_arr = [0, 0]
	for ele in arr:
		max_arr = two_max(max_arr, ele)
	return m // (k + 1) * (max_arr[0] * k + max_arr[1]) + m % (k + 1) * max_arr[0]
(n, m, k) = map(int, input().split(' '))
arr = map(int, input().split(' '))
result = emotes(n, m, k, arr)
print(result)


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
Max = 0
SMax = 0
ind = 0
for i in range(n):
	if A[i] > Max:
		Max = A[i]
		ind = i
if k >= m:
	print(Max * m)
else:
	for j in range(n):
		if A[j] > SMax and j != ind:
			SMax = A[j]
	c = m // (k + 1)
	d = m % (k + 1)
	print(int(Max * (c * k + d)) + int(SMax * c))


one = input().split()
one = list(map(int, one))
n = one[0]
m = one[1]
k = one[2]
two = input().split()
two = list(map(int, two))
sum = 0
m1 = max(two)
two.pop(two.index(m1))
m2 = max(two)
q = m // (k + 1)
mod = m % (k + 1)
ans = q * (k * m1) + q * m2 + mod * m1
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
b1 = a[-1]
b2 = a[-2]
k += 1
total = m // k
score = 0
score += m % k * b1
score += b1 * (total * (k - 1))
score += b2 * total
print(score)


h = 0
nmk_in = input()
nmk = list(map(int, nmk_in.split(' ')))
m = nmk[1]
k = nmk[2]
emotes_in = input()
emotes = list(map(int, emotes_in.split(' ')))
emotes.sort()
emotes.reverse()
n1 = m // (k + 1)
h += n1 * k * emotes[0] + n1 * emotes[1]
h += (m - (k + 1) * n1) * emotes[0]
print(h)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
first_b = 0
second_b = 0
for i in range(n):
	if arr[i] > first_b:
		second_b = first_b
		first_b = arr[i]
	elif arr[i] > second_b:
		second_b = arr[i]
	else:
		continue
one_seq = k * first_b + second_b
ans = m // (k + 1) * one_seq + m % (k + 1) * first_b
print(ans)


(n, m, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
r = l[-1] * k + l[-2]
print(m // (k + 1) * r + m % (k + 1) * l[-1])


l = input().split()
n = int(l[0])
m = int(l[1])
k = int(l[2])
l = input().split()
li = [int(i) for i in l]
li.sort()
max1 = li[-1]
max2 = li[-2]
curr = 0
av = 1
sumi = 0
ans = m // (k + 1) * (k * max1 + max2) + m % (k + 1) * max1
print(ans)


(N, M, K) = map(int, input().split())
A = [int(a) for a in input().split()]
A = sorted(A)
m1 = A[-1]
m2 = A[-2]
a = M // (K + 1)
b = M % (K + 1)
print(a * (m1 * K + m2) + m1 * b)


(n, m, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
p = m // (k + 1)
q = m % (k + 1)
res = (a[-1] * k + a[-2]) * p + a[-1] * q
print(res)


(n, m, k) = map(int, input().split())
z = list(map(int, input().split()))
z.sort()
x = z[-1]
y = z[-2]
t = m // (k + 1)
total = k * x + y
total = total * t
if m % (k + 1) == 0:
	print(total)
else:
	print(total + m % (k + 1) * x)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
best = a[-1]
second = a[-2]
times_s = m // (k + 1)
times_best = m - times_s
ans = times_best * best + times_s * second
print(ans)


nmk = list(map(int, input().split()))
m = nmk[1]
k = nmk[2]
mas = list(map(int, input().split()))
max1 = max(mas)
del mas[mas.index(max1)]
max2 = max(mas)
L = m // (k + 1)
r = m - L * (k + 1)
print(L * (k * max1 + max2) + r * max1)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
lar = max(a)
a.remove(lar)
lar2 = max(a)
q = m // (k + 1)
p = m % (k + 1)
res = (k * lar + lar2) * q + lar * p
print(res)


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
(l, sl) = (a[-1], a[-2])
t = l * k + sl
p = m // (k + 1)
c = t * p
c += l * (m % (k + 1))
print(c)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
Max1 = max(a)
a.remove(Max1)
Max2 = max(a)
complete = m // (k + 1)
happiness = Max1 * (complete * (k + 1) - complete)
happiness += Max2 * complete
happiness += m % (k + 1) * Max1
print(happiness)


(n, m, k) = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
a = l[0]
b = l[1]
if k == m:
	print(a * k)
else:
	x = m % (k + 1) + m // (k + 1) * k
	y = m // (k + 1)
	print(a * x + y * b)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
q = m // (k + 1)
r = m % (k + 1)
s = q * k * a[0] + q * a[1] + r * a[0]
print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a)
cnt = 0
i = 0
while i < n:
	if a[i] == ma:
		cnt += 1
	i += 1
ans = m * ma
if cnt == 1:
	ma2 = 0
	i = 0
	while i < n:
		if a[i] < ma:
			ma2 = max(ma2, a[i])
		i += 1
	ans -= (ma - ma2) * int(m / (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
f = list(reversed(sorted(list(map(int, input().split())))))
x = 0
if m % (k + 1) == 0:
	x = m / (k + 1)
	print(str(int(x * (k * f[0] + f[1]))))
else:
	x = int(m / (k + 1))
	answ = int(x * (k * f[0] + f[1]))
	answ += f[0] * (m % (k + 1))
	print(answ)


(n, m, k) = map(int, input().split())
p = list(map(int, input().split()))
ma = max(p)
p.remove(ma)
na = max(p)
if m % (k + 1):
	t = m // (k + 1)
	l = m % (k + 1)
	print((ma * k + na) * t + ma * l)
else:
	t = m // (k + 1)
	print((ma * k + na) * t)


(n, m, k) = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
(l, z) = (a[-1], a[-2])
x = m % (k + 1)
print((l * k + z) * (m // (k + 1)) + l * (m % (k + 1)))


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
b = sorted(list(map(int, input().split())), reverse=True)
p = b[0]
q = b[1]
s = int(m // (k + 1))
r = m % (k + 1)
l = k * b[0] + b[1]
print(s * l + r * b[0])


(n, m, k) = [int(i) for i in input().split()]
N = [int(i) for i in input().split()]
N.sort()
a = m // (k + 1)
if a == 0:
	H = N[-1] * m
else:
	H = (N[-1] * k + N[-2]) * a + N[-1] * (m % (k + 1))
print(H)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
mint = m // (k + 1)
ans = 0
if m - mint > mint:
	ans = a[n - 1] * (m - mint) + a[n - 2] * mint
else:
	ans = a[n - 1] * mint + a[n - 2] * (m - mint)
print(ans)


(m, n, k) = map(int, input().split())
emotes = list(map(int, input().split()))
rs = 0
emotes.sort()
emotes.reverse()
lan = k + 1
mot = emotes[0] * k + emotes[1]
rs = int(n / lan) * mot
rs += n % lan * emotes[0]
print(rs)


def inpl():
	return list(map(int, input().split()))
(N, M, K) = inpl()
A = inpl()
A.sort()
ma = A[-1]
sa = A[-2]
l = M // (K + 1)
p = M % (K + 1)
print((K * l + p) * ma + l * sa)


(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
top = max(a)
a.pop(a.index(max(a)))
next = max(a)
c = m // (k + 1)
i = top * k + next
tot = c * i + m % (k + 1) * top
print(tot)


(n, m, k) = map(int, input().split())
li = sorted(list(map(int, input().split())))
(ma, ma2) = (li[-1], li[-2])
div = m // (k + 1)
mod = m % (k + 1)
print((ma * k + ma2) * div + ma * mod)


(n, m, k) = [int(_) for _ in input().split()]
em = list(map(int, input().split()))
f = 0
f_i = None
s = 0
s_i = None
for i in range(len(em)):
	if em[i] > f:
		f = em[i]
		f_i = i
for i in range(len(em)):
	if em[i] > s and i != f_i:
		s = em[i]
		s_i = i
fulls = m // (k + 1)
rem = m % (k + 1)
ans = fulls * (k * f + s) + rem * f
print(ans)


[n, m, k] = input('').split(' ')
values = input('').split(' ')
values = [int(i) for i in values]
values.sort(reverse=True)
n = int(n)
m = int(m)
k = int(k)
plusplus = values[0]
plus = values[1]
l = m // (k + 1)
alpha = m - l * (k + 1)
score = k * l * plusplus + l * plus + alpha * plusplus
print(score)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
mx = max(a)
if a.count(mx) > 1:
	print(mx * m)
else:
	mx2 = max(filter(lambda x: x != mx, a))
	x = k * mx + mx2
	y = m // (k + 1)
	z = m % (k + 1)
	print(x * y + z * mx)


inp1 = input()
inp2 = input()
input1 = inp1.split(' ')
input2 = inp2.split(' ')
n = int(input1[0])
m = int(input1[1])
k = int(input1[2])
input2 = [int(x) for x in input2]
input2 = sorted(input2, key=int, reverse=True)
answer = 0
if m % (k + 1) == 0:
	answer = answer + input2[0] * k + input2[1]
	answer = answer * (m / (k + 1))
else:
	answer = answer + input2[0] * k + input2[1]
	answer = answer * int(m / (k + 1))
	answer = answer + m % (k + 1) * input2[0]
print(int(answer))


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
c = m // (k + 1)
p = (m - c) * l[0] + c * l[1]
print(p)


(n, m, k) = map(int, input().split())
s = input().split()
nhi = 0
nhat = 0
for i in range(n):
	if int(s[i]) > nhat:
		nhi = nhat
		nhat = int(s[i])
	elif int(s[i]) == nhat:
		nhi = nhat
	elif int(s[i]) > nhi:
		nhi = int(s[i])
number_group = m // (k + 1)
remain = m % (k + 1)
total = (k * nhat + nhi) * number_group + remain * nhat
print(total)


fd = open(0, 'r')
(n, m, k) = map(int, fd.readline().split())
emotes = list(map(int, fd.readline().split()))
fd.close()
emotes.sort(reverse=True)
s = k * emotes[0] + emotes[1]
s = s * (m // (k + 1))
s += emotes[0] * (m % (k + 1))
print(s)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
m1 = max(l)
l.remove(m1)
m2 = max(l)
ans = m // (k + 1) * (k * m1 + m2) + m % (k + 1) * m1
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
x = max(l)
xcnt = l.count(x)
y = 0
for i in range(n):
	if l[i] < x:
		if l[i] > y:
			y = l[i]
if m == 1:
	print(x)
elif xcnt > 1:
	print(x * m)
else:
	t1 = m // (k + 1)
	t2 = m % (k + 1)
	ans = 0
	ans += y * t1
	ans += t1 * k * x
	ans += t2 * x
	print(ans)


def main():
	(n, m, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	happy = 0
	nums.sort(reverse=True)
	happy = int(m / (k + 1)) * (k * nums[0] + nums[1])
	happy += m % (k + 1) * nums[0]
	print(happy)
main()


from sys import stdin, stdout
from collections import defaultdict as dd
inp = lambda : (int(o) for o in stdin.readline().split())
sinp = lambda : (o for o in stdin.readline().split())
out = lambda : stdout.write(str())
I = lambda : map(int, input().split())
Y = lambda : int(input())
(n, m, k) = I()
a = list(I())
a.sort()
h = 0
x = m // (k + 1)
print(a[-1] * (x * k + m % (k + 1)) + a[-2] * x)


(n, m, k) = list(map(int, input().split()))
values = list(map(int, input().split()))
x = sorted(values)
fir = x[n - 1]
sec = x[n - 2]
print((fir * k + sec) * (m // (k + 1)) + fir * (m % (k + 1)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
ma = max(a)
if a.count(ma) > 1:
	print(ma * m)
else:
	a.remove(ma)
	ma2 = max(a)
	z = m // (k + 1)
	su = k * z * ma + z * ma2
	su += m % (k + 1) * ma
	print(su)


str = input()
n = int(str.split(' ')[0])
m = int(str.split(' ')[1])
k = int(str.split(' ')[2])
a = []
r = 0
str = input()
for i in str.split(' '):
	a.append(int(i))
a.sort(reverse=True)
if m <= k:
	print(a[0] * k)
else:
	raz = int(m / (k + 1))
	r = int(a[0] * raz * k)
	r += int(a[1] * raz)
	r += int(a[0] * (m - (raz * k + raz)))
	print(r)


(n, m, k) = map(int, input().split())
li = list(map(int, input().split()))
tt = sorted(li, reverse=True)
t1 = tt[0]
t2 = tt[1]
cycle = m // (k + 1)
rem = m % (k + 1)
res = (t1 * k + t2) * cycle
res += t1 * rem
print(res)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
m1 = arr[-1]
m2 = arr[-2]
out = 0
temp = m1 * k + m2
times = m // (k + 1)
rem = m % (k + 1)
out = temp * times
out += rem * m1
print(out)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
sum = m // (k + 1) * (arr[0] * k + arr[1]) + m % (k + 1) * arr[0]
print(sum)


import sys
(n, m, k) = [int(tmp) for tmp in sys.stdin.readline().split()]
a = [int(tmp) for tmp in sys.stdin.readline().split()]
mxa1 = max(a)
mxa1i = a.index(mxa1)
mxa1ic = mxa1i + 1
mxa2 = max(a[:mxa1i] + a[mxa1ic:])
mxa2ic = a.index(mxa2) + 1
ec = 0
ec += m // (k + 1) * mxa2
ec += (m // (k + 1) * k + m % (k + 1)) * mxa1
print(ec)


from sys import stdin, stdout
(n, m, k) = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort(reverse=True)
ans = m // (k + 1) * (A[0] * k + A[1]) + m % (k + 1) * A[0]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
e = sorted(a)
best = e[-1]
second = e[-2]
happy = (best * k + second) * (m // (k + 1)) + best * (m % (k + 1))
print(happy)


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

def ca():
	return input().split()

def ii():
	return int(input())
(n, m, k) = ia()
a = ia()
a = list(sorted(a, reverse=True))
c = 0
x = a[0]
y = a[1]
p = m // (k + 1)
print(p * k * x + p * y + m % (k + 1) * x)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
if m == k:
	print(k * a[0])
else:
	check = m // (k + 1)
	remaining = m - check * k - check
	ans = check * k * a[0] + check * a[1] + remaining * a[0]
	print(ans)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
(m1, m2) = (1, 1)
for x in a:
	if x > m2:
		if x > m1:
			m2 = m1
			m1 = x
		else:
			m2 = x
print(m1 * m - m // (k + 1) * (m1 - m2))


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
max = l[0]
sec_max = -1
for i in range(n - 1):
	if max < l[i + 1]:
		sec_max = max
		max = l[i + 1]
	elif sec_max < l[i + 1]:
		sec_max = l[i + 1]
ans = 0
len = int(m / (k + 1))
ans += len * (k * max + sec_max)
l2 = int(m % (k + 1))
ans += max * l2
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
p = max(a)
a.remove(p)
c = max(a)
b = m // (k + 1)
b = b * (k * p + c)
c = m % (k + 1)
c = c * p
print(b + c)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.reverse()
kol = m // (k + 1) * (a[0] * k + a[1])
kol += m % (k + 1) * a[0]
print(kol)


(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
a = max(arr)
for i in range(n):
	if arr[i] == a:
		arr[i] = -1
		break
b = max(arr)
print(m // (k + 1) * b + (m - m // (k + 1)) * a)


(n, m, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = 0
max1 = max(a)
for i in range(n):
	if a[i] == max1:
		a[i] = 0
		break
max2 = max(a)
v = m // (k + 1)
s += v * (max1 * k + max2)
c = m % (k + 1)
s += c * max1
print(s)


(n, m, k) = map(int, input().split())
array = list(map(int, input().split()))
a = max(array)
array.remove(a)
b = max(array)
s = m // (k + 1) * a * k + b * (m // (k + 1)) + m % (k + 1) * a
print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
maxm = a[-1]
smaxm = a[-2]
count = 0
sum = 0
t = maxm * k + smaxm
sum = m // (k + 1) * t
sum += m % (k + 1) * a[-1]
print(sum)


(a, b, c) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = p.pop(p.index(max(p)))
s = p.pop(p.index(max(p)))
if b <= c:
	print(b * q)
else:
	print(int(b / (c + 1)) * (q * c + s) + (b - int(b / (c + 1)) * (c + 1)) * q)


(n, m, k) = map(int, input().strip().split())
lst = sorted(list(map(int, input().strip().split())))[:n]
print(m // (k + 1) * (lst[-1] * k + lst[-2]) + m % (k + 1) * lst[-1])


(n, m, k) = map(int, input().split())
S = list(map(int, input().split()))
s = 0
max1 = max(S)
S.remove(max1)
max2 = max(S)
s += (max1 * k + max2) * (m // (k + 1))
if m % (k + 1) > 0:
	s += max1 * (m % (k + 1))
print(s)


(n, m, k) = map(int, input().split())
l1 = [int(x) for x in input().split()]
big = max(l1)
l1.remove(max(l1))
smol = max(l1)
ans = m % (k + 1) * big
ans += m // (k + 1) * big * k
ans += m // (k + 1) * smol
print(ans)


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
maxi = l[-1]
val = l[-2]
if maxi == val:
	print(maxi * m)
else:
	ans = (maxi * k + val) * (m // (k + 1))
	ans += maxi * (m % (k + 1))
	print(ans)


lin = [int(i) for i in input().split()]
n = lin[0]
m = lin[1]
k = lin[2]
v = [int(i) for i in input().split()]
v.sort(reverse=True)
qtd = m // (k + 1)
ans = v[0] * qtd * k + v[1] * qtd
if m % (k + 1) != 0:
	r = m % (k + 1)
	ans += r * v[0]
print(ans)


(n, m, k) = map(int, input().split())
l = [*map(int, input().split())]
l.sort()
(a, b) = (l[-1], l[-2])
res = 0
x = m // (k + 1)
res += x * (k * a + b)
res += m % (k + 1) * a
print(res)


def f(l, m, k):
	l.sort(reverse=True)
	n2 = m // (k + 1)
	return m * l[0] - n2 * (l[0] - l[1])
(n, m, k) = list(map(int, input().split()))
al = list(map(int, input().split()))
print(f(al, m, k))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if k == m:
	print(m * a[n - 1])
	exit()
d = m // (k + 1)
print(d * a[n - 2] + (m - d) * a[n - 1])


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
f = a[-1] * k + a[-2]
ans = f * (m // (k + 1))
ans += a[-1] * (m % (k + 1))
print(ans)


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007

def power(base, power):
	MOD = 1000000007
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
(n, m, k) = Ints()
a = Array()
a = sorted(a, reverse=True)
segments = m // (k + 1)
res = segments * k * a[0] + segments * a[1]
x = m % (k + 1)
if x <= k:
	res += x * a[0]
print(res)


for _ in range(1):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	m1 = a[-1]
	m2 = a[-2]
	s = 0
	r = m % (k + 1)
	t = m // (k + 1)
	print(t * (m1 * k + m2) + r * m1)


(n, m, k) = map(int, input().split())
s = [int(i) for i in input().split()]
a = max(s)
del s[s.index(max(s))]
b = max(s)
r = m // (k + 1)
z = m % (k + 1)
c = r * (k * a + b) + z * a
print(c)


import math
import os
import random
import re
import sys
(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)
s = 0
f = k * l[0] + l[1]
s += m // (k + 1) * f
s += m % (k + 1) * l[0]
print(s)


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
a = a[-2:]
if k > m:
	sum = k * a[-1]
else:
	b = m // (k + 1)
	c = m % (k + 1)
	sum = b * (a[0] + a[1] * k) + c * a[1]
print(sum)


a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = a[1] // (a[2] + 1)
b.sort()
print(b[len(b) - 2] * c + (a[1] - c) * b[len(b) - 1])


def main():
	(n, m, k) = map(int, input().split())
	nums = sorted(map(int, input().split()))
	x = m // (k + 1)
	ans = x * (k * nums[-1] + nums[-2])
	m %= k + 1
	while m > 0:
		ans += min(m, k) * nums[-1]
		m -= min(m, k)
		ans += min(m, 1) * nums[-2]
		m -= min(m, 1)
	print(ans)
main()


(n, m, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a = sorted(a, reverse=True)
res = 0
res += a[1] * (m // (k + 1))
no = m - m // (k + 1)
res += a[0] * no
print(res)


(n, m, k) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
mm = max(a)
if a.count(mm) > 1:
	print(mm * m)
else:
	a.remove(mm)
	mn = max(a)
	print(m // (k + 1) * (mm * k + mn) + m % (k + 1) * mm)


nmk = input().strip().split(' ')
n = int(nmk[0])
m = int(nmk[1])
k = int(nmk[2])
emojis = input().strip().split(' ')
emojis = [int(x) for x in emojis]
max1 = max(emojis)
emojis.remove(max1)
max2 = max(emojis)
seq = max1 * k + max2
happ = m // (k + 1) * seq + m % (k + 1) * max1
print(happ)


(n, m, k) = list(map(int, input().split()))
e = sorted(list(map(int, input().split())), reverse=True)
f = m // (k + 1)
print(f * e[1] + (m - f) * e[0])


(m, n, k) = list(map(int, input().split()))
t = list(map(int, input().split()))
t.sort()
a = n // (k + 1)
b = n % (k + 1)
print(t[-1] * a * k + t[-2] * a + b * t[-1])


(n, m, k) = map(int, input().split())
A = map(int, input().split())
A = sorted(A)
(M2, M) = A[-2:]
reps = m // (k + 1)
ans = M * (m - reps) + M2 * reps
print(ans)


(n, m, k) = map(int, input().split())
a = [int(_) for _ in input().split()]
a.sort()
a.reverse()
l = a[0]
sl = a[1]
q = m // (k + 1)
r = m % (k + 1)
ans = q * k * a[0] + r * a[0] + q * a[1]
print(ans)


p = input().rstrip().split(' ')
q = input().rstrip().split(' ')
m = int(p[1])
k = int(p[2])
q.sort(key=int, reverse=True)
a = 0
if len(q) == 1:
	if k >= m:
		print(int(q[0]) * m)
	else:
		print(int(q[0]) * k)
elif k >= m:
	print(int(q[0]) * m)
else:
	s = 0
	g = m // (k + 1)
	s = s + int(q[1]) * g
	B = m - g
	s = s + int(q[0]) * B
	print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if a[-1] == a[-2]:
	print(a[-1] * m)
else:
	q = m // (k + 1)
	r = m - q * (k + 1)
	print((k * a[-1] + a[-2]) * q + r * a[-1])


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
if n > 1:
	l1.sort()
	(a, b) = (l1[-1], l1[-2])
	print((a * k + b) * (m // (k + 1)) + a * (m % (k + 1)))
else:
	print(min(k, m) * l1[0])


(N, M, K) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = M // (K + 1)
b = M % (K + 1)
ans = (a * K + b) * l[0] + a * l[1]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
v0 = a[0]
v1 = a[1]
(times, additional) = divmod(m, k + 1)
print((v0 * k + v1) * times + v0 * additional)


list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)
(n, m, k) = map(int, input().split())
a = list_int_input(input())
(maxx1, maxx2) = (0, 0)
for i in a:
	if i > maxx1:
		(maxx1, maxx2) = (i, maxx1)
	elif i > maxx2:
		maxx2 = i
k += 1
value = (maxx1 * (k - 1) + maxx2) * int(m / k) + maxx1 * (m % k)
print(value)


(n, m, k) = map(int, input().split())
a = sorted(list(map(int, input().split())))
if k == m:
	print(a[-1] * k)
else:
	s = (a[-1] * k + a[-2]) * (m // (k + 1)) + m % (k + 1) * a[-1]
	print(s)


(n, k, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
maxim = arr[-1]
second_maxim = arr[-2]
allowed = int(k / (m + 1))
sum_by_maxim = maxim * m * allowed
sum_second_maxim = second_maxim * allowed
sum_by_maxim += (k - allowed * (m + 1)) * maxim
print(sum_second_maxim + sum_by_maxim)


(n, k, m) = map(int, input().split())
list1 = [int(n) for n in input().split()]
max1 = max(list1)
list1.remove(max1)
max2 = max(list1)
res = int(k / (m + 1)) * (m * max1 + max2) + k % (m + 1) * max1
print(int(res))


(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l, reverse=True)
ans = l[0] * (m - m // (k + 1)) + l[1] * (m // (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
m1 = max(a)
m2 = -1
for i in range(n):
	if a[i] == m1:
		a[i] = 0
		break
m2 = max(a)
ans = m // (k + 1) * m2 + (m - m // (k + 1)) * m1
print(ans)


(n, m, k) = map(int, input().split())
a = [int(e) for e in input().split()]
a.sort()
(A, B) = (a[-1], a[-2])
c = m % (k + 1)
ans = c * A + (A * k + B) * (m // (k + 1))
print(ans)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
s = 0
ma1 = a[-1]
ma2 = a[-2]
us = m // (k + 1)
os = m % (k + 1)
res = us * (k * ma1 + ma2) + os * ma1
print(res)


from sys import stdin, stdout
(n, m, k) = map(int, stdin.readline().split())
lst = [int(i) for i in stdin.readline().split()]
lst.sort()
cyc = m // (k + 1)
ans = (m - cyc) * lst[-1] + cyc * lst[-2]
stdout.write(str(ans))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
(mx, mxx) = (0, 0)
for i in a:
	if i >= mx:
		mxx = mx
		mx = i
	elif i > mxx:
		mxx = i
if k == m:
	print(mx * m)
else:
	x = m // (k + 1)
	ans = x * (mx * k + mxx) + (m - (k + 1) * x) * mx
	print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
i = 0
x = m // (k + 1)
y = m % (k + 1)
ans = x * (a[n - 1] * k + a[n - 2]) + y * a[n - 1]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
max1 = max(a[0], a[1])
max2 = a[0] + a[1] - max1
for i in range(2, n):
	if a[i] >= max1:
		max2 = max1
		max1 = a[i]
	elif a[i] > max2:
		max2 = a[i]
print(max1 * (m - m // (k + 1)) + max2 * (m // (k + 1)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
a.sort()
q = m // (k + 1)
s = q * (k * a[n - 1] + a[n - 2])
m -= q * (k + 1)
s += m * a[n - 1]
print(s)


I = lambda : map(int, input().split())
(_, m, k) = I()
(*_, b, a) = sorted(I())
(x, y) = divmod(m, k + 1)
print(x * (a * k + b) + a * y)


import math
(n, m, k) = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
a = l[0]
b = l[1]
cnt = math.floor(m / (k + 1))
c = m % (k + 1)
print(cnt * (a * k + b) + c * a)


(n, m, k) = map(int, input().split())
a = sorted(map(int, input().split()))
largest = a[n - 1]
second = a[n - 2]
groups = m // (k + 1)
ans = largest * groups * k
ans += second * groups
ans += largest * (m % (k + 1))
print(ans)


(n, m, k) = map(int, input().split())
inp = [*map(int, input().split())]
inp.sort(reverse=True)
X = inp[0]
Y = inp[1]
i = 0
kk = m // (k + 1)
ans = kk * X * k + kk * Y
ans += m % (k + 1) * X
print(ans)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
partialsum = a[0] * k + a[1]
nums = k + 1
summ = 0
if m % nums == 0:
	print(int(partialsum * (m / nums)))
else:
	summ += partialsum * (m // nums)
	x = m % nums
	summ += a[0] * x
	print(int(summ))


(n, times, spam) = map(int, input().split())
arr = [int(x) for x in input().split()]
arr.sort(reverse=True)
print(arr[0] * (times % (spam + 1)) + times // (spam + 1) * (arr[0] * spam + arr[1]))


nmk = input().split(' ')
(n, m, k) = (int(nmk[0]), int(nmk[1]), int(nmk[2]))
ln = [int(a) for a in input().split(' ')]
mx = max(ln)
sm = 0
if ln.count(mx) > 1:
	sm = mx
else:
	ln.remove(mx)
	sm = max(ln)
print(m // (k + 1) * (mx * k + sm) + m % (k + 1) * mx)


[n, m, k] = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
	print(a[0] * k)
else:
	mx = 0
	for i in range(n):
		if a[i] > mx:
			midx = i
			mx = a[i]
	smx = 0
	for i in range(n):
		if a[i] > smx and (not i == midx):
			smidx = i
			smx = a[i]
	q = m // (k + 1)
	r = m - q * (k + 1)
	if r > k:
		print(q * k * mx + q * smx + smx + (r - 1) * mx)
	else:
		print(q * k * mx + q * smx + r * mx)


(n, m, k) = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.reverse()
a = x[0]
b = x[1]
j = m // (k + 1)
s = 0
s = s + j * (k * a + b)
j = m % (k + 1)
s += j * a
print(int(s))


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
(n, m, k) = ri()
a = ri()
a.sort()
one = a[-1]
two = a[-2]
ans = 0
if k == 1:
	ans += two * (m // 2)
	ans += one * (m // 2) + one * (m % 2)
	print(ans)
else:
	now = one * k + two
	many = m // (k + 1)
	ans += now * many
	m = m % (k + 1)
	f = 0
	while m > 0:
		if f == 0:
			ans += one * min(k, m)
			f ^= 1
			m -= k
		else:
			ans += two
			f ^= 1
			m -= 1
	print(ans)