First of all, in this kind of problems is essential to specify what our mechanical system is, so we can distinguish between external and internal forces. This way we can apply Newton's laws without confusion.
Let me consider the three masses plus the rope as our system, so an external agent is applying a force $F$ upon it, producing two tensions (internal forces): $T_{32}$ between $M_3$ and $M_2$ and $T_{21}$ between $M_2$ and $M_1$, according to your drawing. The total mass of the system is indeed the sum of the three of them, assuming the rope is massless. Applying Newton's Second Law about some horizontal axis give us:
\begin{equation}
F = (M_1+M_2+M_3)a_{s} ,
\end{equation}
where $a_{s}$ is the system's acceleration. Here is something important to clarify about your reasoning: the system's acceleration is not the sum of the individual accelerations. In fact, after $F$ is transmitted through the rope, the objects acquire the same acceleration despite the different masses. An intuitive way to think about this is to suppose the accelerations are $\textbf{not}$ equal. In this scenario the rope would bend, so tension would not act anymore and the objects would crash, and this of course doesn't happen.
Getting back to the problem, the accelerations are:
\begin{equation}
a_s=a_1=a_2=a_3=\frac{F}{M_1+M_2+M_3}.
\end{equation}
Now we can apply Newton's Second Law to every mass individually, but instead of doing Free Body diagrams and stuff, let's do it in an intuitive way; developing intuition in Physics is much more valuable. If we remove $M_3$ from the system that you drew, we note that the rope would have another free end, but this one would fall to the ground, and
applying the force $F$ at the other end would not disturb this end at all in that sense, physically meaning that tension is zero in that chunk of rope. This way, $T_{32}$ is only dependent upon $M_3$, and we get the equation:
\begin{align}
T_{32}&=M_3 a_s \\
&=\frac{M_3}{M_1+M_2+M_3}F.
\end{align}
Applying the same reasoning for $T_{21}$, we note that removing $M_3$ and $M_2$ from the system will make this chunk of rope hit the ground, and $F$ won't tense it. This way, $T_{21}$ only depends upon the masses $M_3$ and $M_2$, so we obtain:
\begin{align}
T_{21}&=(M_3+M_2)a_s \\
&=\frac{M_3+M_2}{M_1+M_2+M_3}F.
\end{align}
Note: Of course you can also analyze the forces acting upon every individual mass and solve for the tensions. This way, the equation $M_1 a_1 = F-T_1$ that you point out is correct.