Problems
Bessie the cow was excited to recently return to in-person learning! Unfortunately, her instructor, Farmer John, is a very boring lecturer, and so she ends up falling asleep in class often.
Farmer John has noticed that Bessie has not been paying attention in class. He has asked another student in class, Elsie, to keep track of the number of times Bessie falls asleep in a given class. There are
Elsie, feeling very competitive with Bessie, wants to make Farmer John feel like Bessie is consistently falling asleep the same number of times in every class -- making it appear that the issue is entirely Bessie's fault, with no dependence on Farmer John's sometimes-boring lectures.
The only ways Elsie may modify the log are by combining two adjacent class periods or splitting a class period into two. For example, if
Given
Input
The first line of each test case contains
Output
For each
Example
6
1 2 3 1 1 4
7
1
2
3
4
5
6
12
6
6
4
5
-1
4
5