P7659 [COCI 2014/2015 #5] FUNGHI

Description

Hansel and Gretel got a pizza cut into $8$ slices. Each slice has a different number of mushrooms, denoted by $S_1,S_2,...,S_8$. Gretel really likes mushrooms, so she wants to find four consecutive slices whose total number of mushrooms is as large as possible. Note that since the pizza is circular, slice $1$ is adjacent to slice $8$.

Input Format

There are $8$ lines in total, each containing one non-negative integer $S_i$ (where $i$ is the line number), representing the number of mushrooms on that slice.

Output Format

Output one integer on a single line: the maximum number of mushrooms on four consecutive slices.

Explanation/Hint

For $100\%$ of the testdata, $0 \leq S_i \leq 50$. Translated from [COCI 2014/2015 CONTEST #5](https://hsin.hr/coci/archive/2014_2015/contest5_tasks.pdf)。 Translated by ChatGPT 5