Miss M not only enjoys inventing interesting legends for programming problems but also loves painting, especially using harmonious color combinations, such as complementary colors from the color wheel. However, this time she decided to choose colors for her painting differently.

Miss M took $n$ color wheels (you can look at the note section to see what a color wheel is), each with different shades consisting of $(a_i+1)$ colors, and has already selected one initial color on each wheel, marking it as used. Then, she will choose each subsequent color using the following algorithm:
\begin{enumerate}
\item Find the longest sequence among all the color wheels of unmarked colors; if there are several, choose any.
\item If the length of such a sequence is odd, take the color exactly in the middle and mark it as used.
\item If the length of such a sequence is even, take one of the two middle colors and mark it as used.
\end{enumerate}

Miss M wants to choose $m$ more colors, and she is also interested in what the maximum length of the sequence of unmarked colors will be before she selects the $(m+n)$-th color.