##### 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 () days, and it had () boxes of plutonium in stock at the end of the -th day.

At the end of the first day, there was a single box (). On
each subsequent day (), it's possible that a buyer
came to withdraw *all* of the plutonium in the warehouse in the morning.
Whether or not that occurred, one new box of plutonium then arrived at
the warehouse in the afternoon. In other words, if a withdrawal occurred
on day , then , and otherwise, .

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 . If , then Luther has no idea how much plutonium the warehouse had in stock at the end of the -th day. Otherwise, if , then Luther believes that the warehouse had exactly boxes of plutonium in stock at the end of the -th day (in other words, that ).

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 . It's also possible that Luther's observations are inconsistent with any possible sequence of events.

#### Subtasks

In test cases worth of the points, .

In test cases worth another of the points, .

#### Input Specification

The first line of input consists of a single integer, .

The next line consists of integers, .

#### 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 rd day. It's also possible for as many as withdrawals to have taken place, on the mornings of the nd, rd, and th days.

In the second case, the warehouse could contain at most boxes of plutonium at the end of the rd day (if no withdrawals had taken place), which is inconsistent with Luther's observed count of .

## Comments