Problem

Source: Greece Junior National Olympiad 2022, Problem 3

Tags: combinatorics



On the board we write a series of $n$ numbers, where $n \geq 40$, and each one of them is equal to either $1$ or $-1$, such that the following conditions both hold: (i) The sum of every $40$ consecutive numbers is equal to $0$. (ii) The sum of every $42$ consecutive numbers is not equal to $0$. We denote by $S_n$ the sum of the $n$ numbers of the board. Find the maximum possible value of $S_n$ for all possible values of $n$.