(defun main (&rest argv) (declare (ignorable argv)) (let* ((query (read))) (dotimes (_ query) (let* ((n (read)) (a 0)) (loop for i = 1 then (* i 2) while (<= i n) do (incf a (* i (floor n (* i 2)))) (incf a (max 0 (- (mod n (* i 2)) i))) finally (incf a (logcount n))) (princ a) (terpri))))) (main)