Let $X\_1, X\_2, X\_3,\dots$ be an i.i.d. sequence of random variables with finite mean. Write $S\_n=X\_1+X\_2+\dots+X\_n$.


Let $N$ be a non-negative integer-valued random variable with finite mean. $N$ may not be independent of the sequence $(X\_i)$. 


Is it necessarily the case that $S\_N$ has finite mean?


Of course, it's true if $N$ is independent of the sequence $(X\_i)$. Then $E(S\_N)=E(N)E(X\_1)$. It's still true if $N$ is a stopping time for the sequence $(X\_i)$.


It's also true if the $X\_i$ have finite variance. Then for any $c>E(X\_i)$, 
the quantity $R\_c=\sup(S\_n-cn)$ has finite mean, and $E(S\_N)\leq cE(N)+E(R\_c)$.



Expectation of a random sum
Edit: I made it a bit clearer and simpler. 


No. You start with noticing that there is no "linear" estimate for the mean of $S\_N$ in terms of the mean of the sample $X$ under the assumption that the mean of $N$ is small. To this end just take $X$ be $0$ with probability $1-p$ and $A$ with probability $p$ so that $Ap$ is small. Now, once we have a sequence $X\_i$ of independent copies of $X$, define $N$ to be $m$ if at least one of $X\_1,\dots,X\_m$ is not $0$ and $0$ otherwise. Then $ES\_N= Apm$ and $EN\le m^2p$ and $EX=Ap$. 


Now choose $A\_j,p\_j,m\_j$ so that $\sum A\_jp\_j<+\infty$, $\sum A\_jp\_jm\_j=+\infty$, $\sum m\_j^2p\_j<+\infty$. For instance, take $m\_j=2^j$, $p\_j=2^{-3j}$, $A\_j=2^{2j}$.


Define the random samples $X^{(j)}$ and random interval lengths $N^{(j)}$ as above using $A\_j,p\_j,m\_j$ in place of $A,p,m$. Put $X=\sum\_j X^{(j)}$, $N=\sum\_j N^{(j)}$. Then $EX$ and $EN$ are finite. Let $X\_i$ be independent copies of $X$. We have $E\sum\_1^N X\_i\ge E\sum\_j \sum\_1^{N^{(j)}}X\_i^{(j)}=\sum\_j A\_jp\_jm\_j=+\infty$.


