For beams with constant stiffness
\begin{aligned} M_{n-1} l_{n}+2 M_{n}\left(l_{n}+l_{n+1}\right)+M_{n+1} l_{n+1}=-6\left(R_{N l}+R_{N} p\right) \end{aligned}For beams with variable stiffness
\begin{aligned} c M_{n-1} l_{n}+2 M_{n}\left(c l_{n}+l_{n+1}\right)+M_{n+1} l_{n+1}=-6\left(c R_{N l}+R_{N} p\right) \end{aligned}You can also find the equation in the following form
\begin{aligned} c M_{n-1} l_{n}+2 M_{n}\left(c l_{n}+l_{n+1}\right)+M_{n+1} l_{n+1}=-6 c \frac{\Omega_{n} a_{n}}{l_{n}}-6 \frac{\Omega_{n+1} b_{n+1}}{l_{n+1}} \end{aligned}