I want to understand how $\sum_{k=1}^n(3k+1)$ has been simplified here:
$$\sum_{k=1}^n(3k+1) = \sum_{k=1}^n 1+3\sum_{k=1}^nk=n+3 \cdot \frac{n(n+1)}{2} = \frac{1}{2} (2n+3n^2 + 3n) = \frac{1}{2}n (3n+5)$$
I understand the first step and the last step.
What I dont understand is how you get from
$$\sum_{k=1}^n 1+3\sum_{k=1}^nk$$
to
$$n+3 \cdot \frac{n(n+1)}{2}$$
We are simpling using that
$$\sum_{k=1}^n 1=\overbrace{1+1+\ldots+1}^{n\text{ copies}}=n$$
and the well known result
$$\sum_{k=1}^nk=\frac{n(n+1)}{2}$$
Refer to the related: