':type nums: List[int]
:rtype: int'

def totalHammingDistance(self, nums):

    result = 0
    for i in xrange(32):
        counts = ([0] * 2)
        for num in nums:
            counts[((num >> i) & 1)] += 1
        result += (counts[0] * counts[1])
    return result
