How to prove that $\sum_{k=1}^{am-1}\left\lfloor\frac ka\right\rfloor=a\sum_{k=1}^{m-1}k$?

Let $n=am+r$ where $0\le r\le a-1$ and $m=\left\lfloor\frac na\right\rfloor$. Of course, by some examples we can see that such a thing is true, but I'm trying to prove that mathematically, simply by change of variables

$$\sum_{k=1}^{am+r}\left\lfloor\frac ka\right\rfloor=a\sum_{k=1}^{m-1}k+(r+1)m$$

But I don't know how to change variables to arrive from LHS to RHS. I've tried like this

$$\sum_{k=1}^{am+r}\left\lfloor\frac ka\right\rfloor=\sum_{k=1}^{am-1}\left\lfloor\frac ka\right\rfloor+\sum_{k=am}^{am+r}\left\lfloor\frac ka\right\rfloor\\ =\sum_{k=1}^{am-1}\left\lfloor\frac ka\right\rfloor+(r+1)m$$

Thus I need to prove that

$$\sum_{k=1}^{am-1}\left\lfloor\frac ka\right\rfloor=a\sum_{k=1}^{m-1}k$$

Could anyone help me, please? Thanks!

HINT: if $k\in\{an,\ldots,a(n+1)-1\}$ then $\lfloor k/a\rfloor=n$. Hence
$$\sum_{k=an}^{a(n+1)-1}\lfloor k/a\rfloor =\sum_{k=an}^{a(n+1)-1} n=n\sum_{k=an}^{a(n+1)-1}1=an$$