a=sorted(map(int,input().split()));print((a[-1]*(2**(int(eval(input()))))+sum(a)-a[-1]))
a=sorted(map(int,input().split()))[::-1];print((a[0]*(2**(int(eval(input()))))+sum(a)-a[0]))
a = sorted(map(int, input().split()))
print((a[-1] * (2 ** (int(eval(input())))) + sum(a) - a[-1]))

a = sorted(map(int, input().split()))[::-1]
print((a[0] * (2 ** (int(eval(input())))) + sum(a) - a[0]))

-a = sorted(map(int, input().split())) -print((a[-1] * (2 ** (int(eval(input())))) + sum(a) - a[-1])) +a = sorted(map(int, input().split()))[::-1] +print((a[0] * (2 ** (int(eval(input())))) + sum(a) - a[0]))