I know stars and bars theorem. I can solve $a_1 + a_2 + a_3 + \cdots + a_n = N;\; 1\leq a_i \leq K$, if $a_i \geq K$. Then we can set $a_i' = a_i - K$ and convert that to $$a_1' + a_2' + a_3' + \cdots a_n' = N + Kn;\; a_i \geq 0$$
Then the number of solutions will be $\dbinom{N+Kn + n - 1}{n-1}$.
But how can I handle this when $a_i \leq K$ ?