Compute Var(x=X1+X2+...+Xn) Compute $Var(X_1+X_2+...+X_n)$ given $X_1,X_2...$ are iid.,$EX=\mu,Var(X)=\sigma ^2$,and $Var(N)=\sigma [n]^2$,
N is a random variable of nonnegative integers independent  with X,
and my solution is:
$Var(X_1+X_2+...+X_n)$
$=E(E((X_1+X_2+...+X_n)^2)-(E(X_1+X_2+...+X_n))^2)$
$=E(E(X_1^2+X_2^2+...+X_n^2)-(n\mu )^2) $
I've already proved $E(X_1+X_2+...+X_n)=n\mu$ and it's 
$=E(E(X_1^2)+E(X_2^2)+...+E(X_n^2)-(nμ)^2)$
(And it is $E(X^2)=\mu^2+Var(X)=\mu ^2+\sigma ^2$)
$=E(n(\mu ^2+\sigma ^2)-(n\mu)^2)$
$=(\mu ^2+\sigma ^2)E(N)-\mu ^2*E(N^2)$
But the key given is $\sigma ^2*E(N)+\mu ^2*Var(N)$,I wonder if there is something wrong with my solution? Thanks for your help!
 A: $\mathbb{E}\left(X_{1}+\cdots+X_{N}\mid N\right)=\mu N$ so that: $$\mathbb{E}\left(X_{1}+\cdots+X_{N}\right)=\mu\mathbb{E}N$$
$\mathbb{E}\left(\left(X_{1}+\cdots+X_{N}\right)^{2}\mid N\right)=\sigma^{2}N+\mu^{2}N^2$
so that: $$\mathbb{E}\left(X_{1}+\cdots+X_{N}\right)^{2}=\sigma^{2}\mathbb{E}N+\mu^{2}\mathbb{E}N^{2}$$
Working out:$$\text{Var}\left(X_{1}+\cdots+X_{N}\right)=\mathbb{E}\left(X_{1}+\cdots+X_{N}\right)^{2}-\left[\mathbb{E}\left(X_{1}+\cdots+X_{N}\right)\right]^{2}$$
we find:
$$\text{Var}\left(X_{1}+\cdots+X_{N}\right)=\sigma^{2}\mathbb{E}N+\mu^{2}\mathbb{E}N^{2}-\mu^{2}\left[\mathbb{E}N\right]^{2}=\sigma^{2}\mathbb{E}N+\mu^{2}\text{Var}N$$

Edit:
$$\mathbb{E}\left(\left(X_{1}+\cdots+X_{N}\right)^{2}\mid N=n\right)=\mathbb{E}\left(X_{1}+\cdots+X_{n}\right)^{2}=$$$$\sum_{i=1}^{n}\sum_{j=1}^{n}\mathbb{E}X_{i}X_{j}=n\mathbb{E}X_{1}^{2}+n\left(n-1\right)\mathbb{E}X_{1}X_{2}$$ 
Here $\mathbb{E}X_{1}^{2}=\text{Var}X_{1}+\left(\mathbb{E}X_{1}\right)^{2}=\sigma^{2}+\mu^{2}$
and $\mathbb{E}X_{1}X_{2}=\mathbb{E}X_{1}\mathbb{E}X_{2}=\mu^{2}$.
This leads to: $$\mathbb{E}\left(\left(X_{1}+\cdots+X_{N}\right)^{2}\mid N=n\right)=n\left(\sigma^{2}+\mu^{2}\right)+n\left(n-1\right)\mu^{2}=n\sigma^{2}+n^{2}\mu^{2}$$
and consequently: $$\mathbb{E}\left(\left(X_{1}+\cdots+X_{N}\right)^{2}\mid N\right)=\sigma^{2}N+\mu^{2}N^{2}$$
