l=[int(_) for _ in input().split()]

k=int(eval(input()))

print((max(l)*2**k+sum(l)-max(l)))
l=[int(_) for _ in input().split()]

print((max(l)*2**int(eval(input()))+sum(l)-max(l)))
l = [int(_) for _ in input().split()]
k = int(eval(input()))
print((max(l) * 2**k + sum(l) - max(l)))

l = [int(_) for _ in input().split()]
print((max(l) * 2 ** int(eval(input())) + sum(l) - max(l)))

-k = int(eval(input())) -print((max(l) * 2**k + sum(l) - max(l))) +print((max(l) * 2 ** int(eval(input())) + sum(l) - max(l)))