Derivative of cumulative sum function A cumulative sum is a sequence of partial sums:
Applying a cumulative sum to $\{a, b, c, d\}$ gives $\{a, a+b, a+b+c, a+b+c+d\}$.
A more formal notation, the cumulative sum function takes an $N$-dimensional vector and produces another $N$-dimensional vector: 
$C(a) : \begin{bmatrix}a_1 \\ \vdots \\a_N\end{bmatrix}  \xrightarrow{}  \begin{bmatrix}C_1 \\\vdots\\C_N\end{bmatrix}$
For example:
$\begin{bmatrix}1\\2\\4\\5\end{bmatrix}  \xrightarrow{}  \begin{bmatrix}1 \\3\\7\\12\\\end{bmatrix}$
The per-element formula is:
$C_N = \sum_{j=1}^N a_j$
Calculating the partial derivatives with respect to $a_i$ when $i = j$ and $i \ne j$:
$i = j$:
$\frac{\partial( \sum_{j=1}^N a_j)}{\partial a_i} =  \sum_{j=1}^N 1$ 
and $i \ne j$:
$\frac{\partial( \sum_{j=1}^N a_j)}{\partial a_i} =  \sum_{j=1}^N 0$ 
Does this look correct?

$\frac{\partial C_N}{\partial a_i}=\frac{\partial C_N}{\partial a_j}=1$ if $C_N=a_1+\cdots+a_N$ and $i,j\in\{1,2,\cdots N\}$ for both $i=j$ and $i\neq j$.
$\frac{\partial C_N}{\partial a_i}=0$ if $i\notin\{1,2,\cdots,N\}$
