n,x = map(int,input().split())
a = list(map(int,input().split()))
y = format(x,"b")
y = list(y)[::-1]
res = 0
for i in range(len(y)):
    if y[i]=="1":
        res += a[i]
print(res)
4455844250c85b213ed235480e5dd06919194d53
<mask token>

<mask token>
for i in range(len(y)):
    if y[i] == '1':
        res += a[i]
print(res)

n, x = map(int, input().split())
a = list(map(int, input().split()))
y = format(x, 'b')
y = list(y)[::-1]
res = 0
for i in range(len(y)):
    if y[i] == '1':
        res += a[i]
print(res)

n,x = map(int,input().split())
a = list(map(int,input().split()))
y = format(x,"b")
y = list(y)[::-1]
res = 0
for i in range(len(y)):
    if y[i]=="1":
        res += a[i]
print(res)