Demand derived from Cobb-Douglas utility, interpretation, check
From (1) and (2) you get 
$$\frac{x_j}{x_i}=\frac{a_j p_i}{a_i p_j},$$
or equivalently,
$$x_j =\frac{a_j p_i}{a_i p_j} x_i.$$
Substituting this into equation 3 for $j=2,...,n$ and $i=1$ (solving for the demand function for good 1) we get
$$M=p_1x_1 + \sum_{j=2}^n p_j  \frac{a_j p_1}{a_1 p_j} x_1$$
$$M=p_1x_1 + \sum_{j=2}^n  \frac{a_j p_1}{a_1} x_1$$
$$M=p_1x_1 + \frac{p_1}{a_1} x_1\sum_{j=2}^n a_j $$
$$M=p_1x_1(1 + \frac{1}{a_1}\sum_{j=2}^n a_j). $$
Finally, solving for $x_1$ we get
$$x_1^* = \frac{M}{p_1}(1+ \frac{\sum_{j=2}^n a_j}{a_1})^{-1}$$
$$x_1^* =\frac{a_1}{\sum_{j=1}^n a_j} \frac{M}{p_1}.$$

Analogously, 
$$x_i^*=\frac{a_i}{\sum_{j=1}^n a_j} \frac{M}{p_i},$$
for $i=1,...,n$.

As is always the case for demand functions derived from a Cobb-Douglas utility function, the consumer spends a constant share of income on each good. To see this, rearrange the previous equation to get
$$p_ix_i^*=\frac{a_i}{\sum_{j=1}^n a_j} M,$$
for $i=1,...,n$.