Woburn Challenge 2018-19 Round 2 - Senior Division

Ethan Hunt has traced a string of illegal plutonium trafficking down to a remote warehouse situated on a frigid island in Nunavut!
The warehouse has been operating for a period of
At the end of the first day, there was a single box (
Ethan has entrusted the task of monitoring the warehouse to his friend
and fellow IMF member Luther Stickell. Accurately monitoring the
warehouse proved problematic, but Luther did his best to come up with a
list of observations
Ethan would now like to use Luther's observations to determine how many
sellers withdrew plutonium from the warehouse. Due to gaps in Luther's
observations, there may be multiple sequences of events which are
consistent with them, so Ethan is interested in both the minimum and
maximum possible number of withdrawals which could have taken place over
the course of days
Subtasks
In test cases worth
In test cases worth another
Input Specification
The first line of input consists of a single integer,
The next line consists of
Output Specification
Output either two integers, the minimum and maximum possible number of
withdrawals, or the single integer -1
if it's impossible for Luther's
observations to be accurate.
Sample Input 1
6
1 0 0 0 3 0
Sample Output 1
1 3
Sample Input 2
3
1 0 4
Sample Output 2
-1
Sample Explanation
In the first case, it's possible that plutonium was only withdrawn a
single time, on the morning of the
In the second case, the warehouse could contain at most
Comments
It might be helpful to know that although the problem statement says that
is always 
, it does not necessarily mean that 
will always be 