Prove that $n$ is also a power of $2$.
Given first term $a$ and common difference $d$, sum of first $n$ terms, $S_n$ is given by $$S_n=\frac{n}{2}\left(2a+(n-1)d\right)$$ Let $S_n=2^k$ where $k\in\mathbb Z$. We must have $k\ge 0$ as the arithmetic progression consists of integers. $$2^k=\frac{n}{2}\left(2a+(n-1)d\right)$$ $$2^{k+1}=n\left(2a+(n-1)d\right)\in\mathbb Z^+$$
As the prime factorization of an integer is unique, $n$ must be of the form $2^r$, where $r\ge0$. Thus, $n$ must be a power of $2$.
The sum of an arithmetic progression equals the number of terms times an integer or a half-integer. If twice the sum is a power of two, then both factors are a power of two.
See that the sum of first $n$ terms is $s = \frac{n * (a_{1} + a_{n})}{2} = 2^{k}(say)$ for $k \in \mathbb{Z}$ ,now both $a_{1},a_{n}$ are integers means that $n$ must be a power of $2$.