This problem is fairly straightforward if log2(n) is a whole number as we can use a simply use:
n * log2(n)/2
however it miscounts when log2(n) isn't a whole number. My intuition is there should be a formula similar to this that works for all n but I'm having trouble finding it.