TITLE: Selecting $p-1$ integers from a set of $p+1$ integers, so that their weighted sum is divisible by $p$.
QUESTION [7 upvotes]: An odd prime number $p$ and a $(p + 1)$-element set $S$ of integers are given.
Prove that it is possible to choose
distinct numbers $a_1, a_2, a_3, \dots, a_{p-1}\in S$ such that
\begin{equation}1\cdot a_1+2\cdot a_2+\cdots + (p-1)a_{p-1} \end{equation}
is a multiple of p.
My observations
For $p=3:$
We have $S=\{a_1,\,  a_2,\, a_3,\, a_4\}$ and we need to show that for some distinct $a_1,a_2\in S$ we have
$$1 \cdot a_1 + 2 \cdot a_2 = 3 \cdot k,$$
for some integer $k$.  This is equivalent to
$a_1 - a_2 = 3(k-a_2), \, k-a_2 = \alpha, $ so $a_1 - a_2 = 3\alpha$.
And I don't know how to continue, could you help me. Thank you in advance.

REPLY [3 votes]: For every choice of $p$ elements $x_0,\ldots,x_{p-1}\in S$ you have
$$k\sum x_i+\sum ix_i=\sum(i+k)x_i\equiv\sum ix_{i-k}\pmod{p},$$
if you consider the indices mod $p$. So it suffices to find $p$ such elements such that their sum is not divisible by $p$, i.e. their sum is a unit mod $p$, so that there exists an integer $k$ such that
$$k\sum x_i+\sum ix_i\equiv0\pmod{p}.$$
If the sum of every choice of $p$ elements is divisible by $p$, then all elements of $S$ are pairwise congruent mod $p$, so any choice of $p-1$ elements from $S$ will do as then
$$\sum ix_i\equiv x_1\sum i=x_1\frac{p(p+1)}{2}\equiv0\pmod{p}.$$