Number of non-negative solutions of an equation with restrictions 
Q: Find the number of non-negative solutions of the equation $$r_1+r_2+r_3+\ldots +r_{2n+1}=R$$ when $0 \le r_i \le \min(N,R)$  and  $0\le R\le (2n+1)N$.

My Attempt:
I tried the stars and bars method but it did not work properly. If the upper-bound for $r_i$ was not there, then the answer would have been $\binom{2n+1+R-1}{R}=\binom{2n+R}{R}$.
But how do I deal with this problem in the given situation?
EDIT: For the problem, you can simply consider $R$ as fixed and I wish to calculate the number of non-negative solutions to the given equation only.

So we have
$$
\left\{ \begin{gathered}
  0 \leqslant R \leqslant \left( {2n + 1} \right)N \hfill \\
  0 \leqslant r_{\,i}  \leqslant \min (N,R) \hfill \\
  r_{\,1}  + r_{\,2}  +  \cdots  + r_{\,2n + 1}  = R \hfill \\ 
\end{gathered}  \right.
$$
understanding (from the context) that the $r_i$ are integers.
The formulation that you give for the bounds is quite peculiar, since from it we get
$$
r_{\,\text{avg}}  = \frac{R}
{{2n + 1}} \leqslant N\quad \quad M = \min (N,R) = \left\{ {\begin{array}{*{20}c}
   N & {\left| {\;\frac{R}
{{2n + 1}} \leqslant N \leqslant R} \right.}  \\
   R & {\left| {\;R \leqslant N} \right.}  \\
 \end{array} } \right.
$$
Now, if the variables are upper limited to $M=N$, then the average will definitely be not greater than $N$,
while if $M=R$, then the upper bound is implied by the sum.  
In any case,  your question turns down to finding (apart the change in denominating the parameters)
$$N_{\,b} (s,r,m) = \text{No}\text{. of solutions to}\;\left\{ \begin{gathered}
  0 \leqslant \text{integer  }x_{\,j}  \leqslant r \hfill \\
  x_{\,1}  + x_{\,2}  +  \cdots  + x_{\,m}  = s \hfill \\ 
\end{gathered}  \right.$$
where $N_{\,b} (s,r,m)$ is given by the closed summation

$$
N_b (s,r,m)\quad \left| {\;0 \leqslant \text{integers  }s,m,r} \right.\quad  = \sum\limits_{\left( {0\, \leqslant } \right)\,\,k\,\,\left( { \leqslant \,\frac{s}
{r}\, \leqslant \,m} \right)} {\left( { - 1} \right)^k \left( \begin{gathered}
  m \hfill \\
  k \hfill \\ 
\end{gathered}  \right)\left( \begin{gathered}
  s + m - 1 - k\left( {r + 1} \right) \\ 
  s - k\left( {r + 1} \right) \\ 
\end{gathered}  \right)} 
$$  

as explained in this post and in in this other one.
