Official solution
\[\begin{aligned}
&\begin{aligned}
& \mathrm{T}_{\mathrm{r}}={ }^{1016} \mathrm{C}_{\mathrm{r}}(5)^{\frac{1016-\mathrm{r}}{2}} 7^{\frac{\mathrm{r}}{8}} \\
& \Rightarrow \mathrm{r}=0,8,16,24, \ldots ., 1016 \\
& 1016=0+(\mathrm{n}-1) 8 \\
& \Rightarrow \mathrm{n}-1=\frac{1016}{8}=127
\end{aligned}\\
\&\text { So, } \mathrm{n}=128 \text {. }
\end{aligned}\]