How to find the n'th number in this sequence The first numbers of the sequence are {2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2}.
I.e. the even indexed elements are 1. Removing those yields a new sequence where the odd indexed elements are 2. Removing those yields a new sequence where the odd indexed elements are 3. Etc.
In fact what I need is the sum of the first $n$ elements for all $n\in\mathbb{N}$. I tried to use the binary digit counts of $n$ but I haven't find something useful.

The $n^\text{th}$ number in the sequence is $1$ more than the number of consecutive $1$'s at the end of the binary representation of $n.$
$$
$$
For any $n \ge 1,$ the sum of the first $n$ members in the sequence is:
$2n$ minus the number of $1$'s in the binary representation of $n$ that are not in a final consecutive block of $1$'s at the rightmost end of the number.
$$
$$
For example:
If $n \ge 2$ is a power of $2,$ then the sum of the first $n$ numbers in the sequence is $2n-1$ (since there's a single $1$ in the binary representation of $n$ and it's not at the far right).
If $n$ is any even number, then the sum of the first $n$ numbers in the sequence is $2n$ minus the total number of $1$'s in the binary representation of $n$ (since none of those $1$'s are at the far right).
If $n$ is $1$ less than a power of $2,$ then the sum of the first $n$ numbers in the sequence is $2n$ (since all the $1$'s in the binary representation of $n$ are in the final consecutive block at the far right).
