Let a1,a2,…,an be the numbers in a line on the blackboard. Since a1+a2+⋯+a40=0, it follows that half of the numbers a1,a2,…,a40 are equal to 1 and the other half are equal to −1. Since a1+a2+⋯+a40+a41+a42=0 it follows that a41=a42=a∈{−1,1}.
Similarly, a2+a3+⋯+a43=0 and hence a42=a43=a∈{−1,1}. Proceeding in the same way we conclude that all numbers after a41 must be equal to a.
Therefore, if n>60, the sum a22+a23+⋯+a61 has a41=a42=⋯=a61=a, and hence 1 and −1 cannot have the same cardinality in the set. It means that a22+a23+⋯+a61=0, and that contradicts condition (i).
Hence the greatest value of n is 60.
The maximal value of Σn is obtained when we have as many as possible numbers equal to 1. We remind that between the first 40 numbers we must have 20 numbers equal to −1. Hence the numbers equal to 1 can be at most 40. Therefore Σn≤20. In fact, we observe that maxΣn=20. It happens for
a1=⋯=a20=1, a21=⋯=a40=−1 and a41=⋯=a60=1