Proving $\left|\sum_{r=1}^{n}\vec{a_{r}}\right|^2=\sum_{r=1}^{n}\left|\vec{a_{r}}\right|^2+2\sum_{r\lt j}\vec{a_{r}}\cdot\vec{a_{j}}$ How to prove the following result. I can interpret the equality for $n=2$ boiling down to the cosine rule in disguise.

$$\left|\sum_{r=1}^{n}\vec{a_{r}}\right|^2=\sum_{r=1}^{n}\left|\vec{a_{r}}\right|^2+2\sum_{r\lt j}\vec{a_{r}}\cdot \vec{a_{j}}$$

And so a proof I came up with was to keep using it like cosine rule and treating the term inside the modulus as sum of two vectors, which I think is just similar to induction applied backwards. Apart from these two proofs, is there a more elegant way to prove it? Thanks.

The trick here is to recognize that $$ \left| \sum_{r=1}^n \overrightarrow{a_r} \right|^2 = \left(\sum_{r=1}^n \overrightarrow{a_r}\right)\cdot\left(\sum_{r=1}^n \overrightarrow{a_r}\right).$$
To make the result really obvious we'll get rid of the sigma notation.
That is,
$$ \left| \sum_{r=1}^n \overrightarrow{a_r} \right|^2 = (\overrightarrow{a_1}+\overrightarrow{a_2}+\dots+\overrightarrow{a_n} )\cdot(\overrightarrow{a_1}+\overrightarrow{a_2}+\dots+\overrightarrow{a_n} ). $$ Expanding the RHS as normal because the dot product is distributive leads to,
$$ \left| \sum_{r=1}^n \overrightarrow{a_r} \right|^2 = \overrightarrow{a_1}\cdot \overrightarrow{a_1} + \overrightarrow{a_1}\cdot \overrightarrow{a_2} + \dots + \overrightarrow{a_1}\cdot \overrightarrow{a_n}+\overrightarrow{a_2}\overrightarrow{a_1}+\dots +\overrightarrow{a_n}\cdot \overrightarrow{a_n}. $$ Recall that the dot product is commutative and that $\overrightarrow{a_r}\cdot \overrightarrow{a_r}=\left|\overrightarrow{a_r}\right|^2$.
By simplifying, we have $$ \left| \sum_{r=1}^n \overrightarrow{a_r} \right|^2 = \left|\overrightarrow{a_1}\right|^2 + 2\overrightarrow{a_1}\cdot \overrightarrow{a_2} + \left|\overrightarrow{a_2}\right|^2 + 2\overrightarrow{a_2}\cdot \overrightarrow{a_3} + \dots + \left|\overrightarrow{a_n}\right|^2 + 2\overrightarrow{a}_{n-1}\cdot \overrightarrow{a_n}.$$
Therefore,
\begin{align*} \left| \sum_{r=1}^n \overrightarrow{a_r} \right|^2 &= \left( \left|\overrightarrow{a_1}\right|^2 + \dots + \left|\overrightarrow{a_n}\right|^2 \right) + 2\left( \overrightarrow{a_1}\cdot \overrightarrow{a_2} + \dots + \overrightarrow{a}_{n-1}\cdot \overrightarrow{a_n}  \right) \\ &= \sum_{r=1}^n \left|\overrightarrow{a_r}\right|^2 + 2\sum_{r<j}\overrightarrow{a}_{j}\cdot \overrightarrow{a_r}\end{align*}
for all $2\leq j \leq n$ where $r\leq j-1$.
