[guided]We introduce a notation that separates the jump sizes $a_n$ from the accumulated sums. For each integer $k$ with $1\le k\le N$, define
\begin{align*}
A_k:=\sum_{n=1}^k a_n.
\end{align*}
Thus $A_k$ is the value attained by the step function after the $k$-th jump, and in particular $A(N)=A_N$.
First consider the endpoint case $N=1$. The interval $[1,1]$ has $\mathcal L^1$-measure $0$, so
\begin{align*}
\int_1^1 A(t)f'(t)\,d\mathcal L^1(t)=0.
\end{align*}
The asserted identity becomes
\begin{align*}
a_1f(1)=A_1f(1),
\end{align*}
which follows from the definition $A_1=a_1$.
Now assume $N\ge 2$. The point of the proof is that $A$ is constant between consecutive integers. If $t\in[k,k+1)$ for an integer $k$ with $1\le k\le N-1$, then the integers $n$ satisfying $1\le n\le N$ and $n\le t$ are exactly $1,\dots,k$. Hence
\begin{align*}
A(t)=\sum_{n=1}^k a_n=A_k.
\end{align*}
The values of $A$ at the finitely many endpoints $2,\dots,N-1$ do not affect the Lebesgue integral, because finite subsets of $\mathbb R$ have $\mathcal L^1$-measure $0$. Also, $A$ is bounded because it takes only finitely many values, and $f'$ is continuous on the compact interval $[1,N]$, so the product $A f'$ is Lebesgue integrable. Therefore we may split the integral over the finite partition into unit intervals:
\begin{align*}
\int_1^N A(t)f'(t)\,d\mathcal L^1(t)
=
\sum_{k=1}^{N-1} A_k\int_k^{k+1} f'(t)\,d\mathcal L^1(t).
\end{align*}
For each $k$, the function $f$ is continuously differentiable on $[k,k+1]$. The one-dimensional fundamental theorem of calculus applies and gives
\begin{align*}
\int_k^{k+1} f'(t)\,d\mathcal L^1(t)=f(k+1)-f(k).
\end{align*}
Substituting this identity into the finite sum yields
\begin{align*}
\int_1^N A(t)f'(t)\,d\mathcal L^1(t)
=
\sum_{k=1}^{N-1} A_k\bigl(f(k+1)-f(k)\bigr).
\end{align*}[/guided]