We toss infinitely many times a coin such that head has probability $p$. Let $A_n$ be an event such that in tosses $2^n$, $2^n+1$, ... , $2^{n+1}-1$ there will be $n$ heads in a row. Prove that if $p<\frac{1}{2}$ then almost surely finitely many $A_n$ will occur and if $p\geq \frac{1}{2}$ then almost surely infinitely many $A_n$ will occur.
My solution:
$P(A_n)=(2^n-n+1)p^n$ (because there are $2^n-n+1$ blocks of length $n$ in $2^n$ block, we put there heads and don't care what happen elsewhere). So for $p\geq \frac{1}{2}$ $P(A_n)$ diverges to infinity as a sequence so $\sum_{k=1}^{\infty}P(A_k)$ is divergent. For $p<\frac{1}{2}$ $\sum_{k=1}^{\infty}P(A_k)$ is convergent as a sum of 3 converging series. $A_n$'s are independent so the result follow from Borel Cantelli lemma.
I think something is wrong, most likely $P(A_n)=(2^n-n+1)p^n$ isn't true, because answer to this question is much more complicated.
Is my solution correct? If something is wrong tell me why.