Sum of sample given a priori knowledge of its maximum Given a sample of discrete random variables $X_1, X_2, \ldots, X_n \sim F$, I am looking to calculate the distribution given by the probability mass function:
$$P\left(\sum_{i=1}^n X_i = x~\middle|~\max_{i=1}^n X_i = a\right)$$
In other words, given that I know the maximum value of the sample, I would like to know the distribution of the sum.
My initial approach to this problem was to define a new distribution $F'$, a truncated version of $F$ supported up to and including $a$, such that we can independently take $Y_1, Y_2, \ldots, Y_{n-1} \sim F'$ and rewrite:
$$P\left(\left(a + \sum_{i = 1}^{n - 1} Y_i\right) = x\right)$$
I was initially expecting this to be an exact solution to the problem, but some inspection seems to indicate that it is not. For small values of $n$, there is a noticable difference in the distribution of my model and the "truth" (gathered by repeatedly drawing samples, and keeping those with the correct maximum).
Here is an example in which $n = 2$, $a = 10$, $F = B(20, 0.5)$, with the blue histogram produced from 10,000 samples:

Is there a way that I can model this distribution exactly? The code used to produce the plot in this question is available in this gist.

This is a only partial answer for the case of $n=2$.  Let $p(x)$ and $F(x)$ denote the pmf and cdf of $X_1$ and $X_2$.  The joint pmf of the minimum and the maximum $X_{(1)},X_{(2)}$ is then clearly
$$
p_{X_{(1)},X_{(2)}}(x_1,x_2)=\begin{cases}
p(x_1)p(x_2) & \text{for }x_1=x_2  \\
2p(x_1)p(x_2) & \text{for }x_1<x_2
\end{cases}
$$
since $X_{(1)},X_{(2)}$ can take the same value only in one way whereas they can take different values in two ways.
Conditional on $X_{(2)}=x_2$ the pmf of $X_{(1)}$ is thus
$$
p_{X_{(1)}|X_{(2)}=x_2}(x_1)=\frac{p_{X_{(1)},X_{(2)}}(x_1,x_2)}{p_{X_{(2)}}(x_2)}.
$$
The cdf of $X_{(2)}$ is
$$
F_{X_{(2)}}(x_2)=F(x_2)^2
$$
and hence the pmf of $X_{(2)}$ is
$$
p_{X_{(2)}}(x_2)=F(x_2)^2-F(x_2-1)^2.
$$
The pmf of the sum conditional on $X_{(2})=a$ is then
$$
P(X_{(1)}+X_{(2)}=x|X_{(2)}=a)=p_{X_{(1)}|X_{(2)}=a}(x-a)
$$
which will agree with your simulations.
