I am trying to calculate the number of iterations of a sequence of nested loops of the form:

begin{equation}

N = sum_{j=0}^{j_T} sum_{k=0}^{j} sum_{l=0}^{k} sum_{n=n_0}^{n_T} 1

end{equation}

where $j_T$ and $n_T$ are known constants.

For $n_0 = 0$ the case is trivial and can be calculated using the standard procedure (Sum number of times statement is executed in triple nested loop)

The problem is that in my case $n_0$ is given by a more complex expression:

begin{equation}

n_0 = minleft(max(0,k-2l),n_Tright) = maxleft(min(k-2l,n_T),0right)

end{equation}

Basically, the initial value of $n$ in the last sum is $k-2l$, except when its value is lower/greater than the lower/greater limits of the sum, in which case it gets replaced by the corresponding extreme value of the interval (either $0$ or $n_T$).

Any ideas?