In the cells of a $1 \times 100$ board, Julián writes all the integers from $1$ to $100$ (inclusive) in any order of his choice, without repeating numbers. For every three consecutive cells on the board, the cell containing the middle value of the three numbers in those cells is marked. For example, if the three numbers are $7$, $99$ and $22$, then the cell with $22$ is marked. Let $S$ be the sum of all the numbers in the marked cells. Determine the minimum value that $S$ can take. Note: Each marked number contributes to the sum $S$ exactly once, but it can be marked multiple times.