a, b = map(int, input().split())
c = list(map(int, input().split()))

d = [0] * (1 << a)
e = [0] * (1 << a)
f = 0

for g in range(1, 1 << a):
    h = 0
    for i in range(a):
        if g & (1 << i):
            h += c[i]
    d[g] = h

unique_costs = set()

for j in range(1, 1 << a):
    unique_costs.add(d[j])

unique_costs = sorted(unique_costs)
print(len(unique_costs))
print(*unique_costs)