Hide

Problem K
The Last Pizza

Languages en sv

Penny and Pontus have bought $N$ pizzas and are currently eating. They are both polite Swedes, so no one wants to take the last slice. Penny can either take the rest of a pizza (provided it has at least one slice) or a slice from one of the pizzas. Then Pontus will do the same, and they will continue taking turns in this way. Given that Penny starts, can she guarantee that Pontus takes the last slice?

Input

The first row contains one integer $N$ ($1 \leq N \leq 3$), the number of pizzas they have bought.
Then follows $N$ lines, that describe the number of slices each pizza has. All pizzas have at least one slice and no pizza has more than $10^9$ slices.

Output

Write ”Ja” if Penny can guarantee that Pontus takes the last piece. Otherwise, write ”Nej”.

Scoring

Your solution will be tested on different test groups. To score points for a group, you must pass all the test cases in that group.

Group

Point value

Constraints

$1$

$16$

$N = 1$

$2$

$22$

$N = 2$

$3$

$28$

Each pizza has at most $100$ slices.

$4$

$34$

No additional constraints.

Explanation of sample 1:

There is one pizza that has two slices. If Penny takes one slice, Pontus will be forced to take the last one. Penny could have taken the entire pizza instead, but would then have failed.

Sample Input 1 Sample Output 1
1
2
Ja
Sample Input 2 Sample Output 2
2
1
3
Ja
Sample Input 3 Sample Output 3
3
5
5
7
Nej

Please log in to submit a solution to this problem

Log in