Apologies for the vague title, I will edit to be more specific as I get feedback. I've been trying to figure out a general solution to this problem, but I'm not even sure what search terms to use.
The basic setup:
We have a variable $x$ that can have $>10^6$ discrete values. This is enough to assume that it is infinite, but only if that helps with calculation.
We have a probability mass function of $p(x)$, where $ \sum_{x=1}^\infty p(x) = 1 $
and a function $g(n)$ that I've determined to look like...
$$ g(1) = \sum_{x_1=1}^\infty p(x_1)^2 $$
$$ g(2) = \sum_{x_1=1}^\infty \sum_{x_2=1}^\infty [p(x_1)^2+p(x_2)^2]^2 $$
$$ ... $$
$$ g(n) = \sum_{x_1=1}^\infty ...\sum_{x_n=1}^\infty [p(x_1)^2\ + \ ...\ + \ p(x_n)^2]^n $$
I would like to find a general formula for $g(n)$ that will allow me to calculate the value for any $n$ from $1$ to $10^6$.
Is this a solved problem? An impossible problem? Any help on where to start thinking about this would be appreciated.