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-th term is equal to the largest power of 2 which divides (n+1), plus 1.
In other words if $n+1=2^lm$ in which l is non-negative and m is odd, then $a_n=l+1$.
(For example the 11-th term is equal to 2+1,since $2^2$ divides 12 but not $2^3$, the 23-th term is equal to 3+1, because $2^3$ is the greatest power which divides 24).
Also we have $a_1+a_2+...+a_n=$ {the largest power of 2 which divides $(n+1)!$ }+n.

In a more formal language
$a_n=v_2(n+1)+1$.
Sum of the first n elements$=n+v_2((n+1)!)$
$v_2(t)$ stands for the largest power of 2 which divides t.
