# Can we still prove $\mathbb{E}[Z] = \mathbb{E}[N]\mathbb{E}[X_1]$ for a sequence of iid variables $X1,X2,\ldots$ when N is not independent

Let $$X_1, X_2,\ldots$$ be a sequence of independent and identically distributed non-negative integer valued random variables, and let $$N$$ be a non-negative integer valued random variable which is independent of the sequence $$X_1,X_2,\ldots$$. Let $$Z = X_1+X_2+\ldots+X_N$$ (where we take $$Z=0$$ if $$N=0$$).

(a) Show that $$\mathbb{E}[Z] = \mathbb{E}[N] \mathbb{E}[X_1]$$.

(b) Suppose we remove the condition that $$N$$ is independent of the sequence ($$X_i$$). Is it still necessarily the case that $$\mathbb{E}[Z] = \mathbb{E}[N] \mathbb{E}[X_1]$$? Find a proof or a counterexample.

I had no problem proving part (a), but am struggling with part (b). Any advice on how to approach part (b) would be greatly appreciated.

Suppose $$X_1$$ is a symmetric Bernoulli random variable and $$N = 1 - X_1$$.
Then $$E[N] = E[X_1] = \frac{1}{2}$$, but $$Z$$ is always $$0$$.