Language: C++

An adult game master and 
N
N children are playing a game on an ice rink. The game consists of 
K
K rounds. In the 
i
i-th round, the game master announces:

Form groups consisting of 
A
i
Ai children each!
Then the children who are still in the game form as many groups of 
A
i
Ai children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.

In the end, after the 
K
K-th round, there are exactly two children left, and they are declared the winners.

You have heard the values of 
A
1
A1, 
A
2
A2, ..., 
A
K
AK. You don't know 
N
N, but you want to estimate it.

Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of 
N
N exist.

Constraints
1
≤
K
≤
10
5
1≤K≤105
2
≤
A
i
≤
10
9
2≤Ai≤109
All input values are integers.
Input
Input is given from Standard Input in the following format:

K
K
A
1
A1 
A
2
A2 
.
.
.
... 
A
K
AK
Output
Print two integers representing the smallest and the largest possible value of 
N
N, respectively, or a single integer 
−
1
−1 if the described situation is impossible.

Sample Input 1 Copy
Copy
4
3 4 3 2
Sample Output 1 Copy
Copy
6 8
For example, if the game starts with 
6
6 children, then it proceeds as follows:

In the first round, 
6
6 children form 
2
2 groups of 
3
3 children, and nobody leaves the game.
In the second round, 
6
6 children form 
1
1 group of 
4
4 children, and 
2
2 children leave the game.
In the third round, 
4
4 children form 
1
1 group of 
3
3 children, and 
1
1 child leaves the game.
In the fourth round, 
3
3 children form 
1
1 group of 
2
2 children, and 
1
1 child leaves the game.
The last 
2
2 children are declared the winners.

Sample Input 2 Copy
Copy
5
3 4 100 3 2
Sample Output 2 Copy
Copy
-1
This situation is impossible. In particular, if the game starts with less than 
100
100 children, everyone leaves after the third round.

Sample Input 3 Copy
Copy
10
2 2 2 2 2 2 2 2 2 2
Sample Output 3 Copy
Copy
2 3

Compiler output:
a.cc:16:170: warning: missing terminating ' character
   16 | Ai children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.
      |                                                                                                                                                                          ^
a.cc:16:170: error: missing terminating ' character
   16 | Ai children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.
      |                                                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:31:12: warning: missing terminating ' character
   31 | AK. You don't know
      |            ^
a.cc:31:12: error: missing terminating ' character
   31 | AK. You don't know
      |            ^~~~~~~ 
a.cc:41:1: error: extended character ≤ is not valid in an identifier
   41 | ≤
      | ^
a.cc:43:1: error: extended character ≤ is not valid in an identifier
   43 | ≤
      | ^
a.cc:46:1: error: extended character ≤ is not valid in an identifier
   46 | 1≤K≤105
      | ^
a.cc:46:1: error: extended character ≤ is not valid in an identifier
a.cc:48:1: error: extended character ≤ is not valid in an identifier
   48 | ≤
      | ^
a.cc:51:1: error: extended character ≤ is not valid in an identifier
   51 | ≤
      | ^
a.cc:54:1: error: extended character ≤ is not valid in an identifier
   54 | 2≤Ai≤109
      | ^
a.cc:54:1: error: extended character ≤ is not valid in an identifier
a.cc:78:1: error: extended character − is not valid in an identifier
   78 | −
      | ^
a.cc:80:1: error: extended character − is not valid in an identifier
   80 | −1 if the described situation is impossible.
      | ^
a.cc:1:1: error: 'An' does not name a type
    1 | An adult game master and
      | ^~