Python lightweight solution


#1

def cntBits(self, a):
res = 0
for i in [sum([(i >> j) & 1 for i in a]) for j in range(len(bin(max(a))) - 2)]:
res += i * (len(a) - i)
return (res << 1) % (10**9 + 7)