Let a1,a2,…,an denote the numbers on the blackboard and let X={1,2,…,n} be the index set.
The remainder corresponding to an index subset A⊆X is the remainder of the sum ∑k∈Aak modulo n and we denote it by σ(A). Here we assume σ(∅)=0. For 0≤k≤n−1, let Sk=∣{A⊆X∣σ(A)≡k(modn)}∣ denote the number of index subsets that give the remainder k. From the assumption, we have S1=S2=⋯=Sp−1=Sp+1=⋯=Sn−1.
Now set N=σ(X)=a1+a2+⋯+an(modn) and consider the sum
T=A⊆X∑σ(A)(modn).
Since each k∈X belongs to exactly 2n−1 subsets, we have T≡2n−1N(modn). On the other hand, we have
T≡k=0∑n−1kSk≡0S0+pSp+(2(n−1)n−p)S1(modn).
Therefore, we get 2n−1N≡p(Sp+2(p−1)S1)(modn) and hence N≡0(modp) since p is odd.