#P10183. [YDOI R1] Running
[YDOI R1] Running
Background
Little Z is going to run. He wants to outpace his classmates after school starts.
Problem Description
Little Z is running on a road. There are supermarkets on the road, and the position of the -th supermarket is . When the time at which Little Z passes a supermarket is odd, he will go shopping there, and then he will be outpaced by his classmates.
Little Z starts at position . Every unit of time, he runs units to the right.
You need to find the maximum value of such that, when Little Z passes each of the supermarkets, he never goes shopping.
It is required that must be a positive integer, and the time Little Z spends to reach any supermarket must be an integer. In other words, you need to ensure that the time when Little Z reaches any supermarket is even. Note that the initial time is .
Input Format
The input has lines.
Line contains one positive integer .
Lines to each contain one positive integer. The positive integer in line is .
Output Format
The output has line.
Output the maximum that satisfies the conditions. If there is no solution, output .
2
1
2
-1
5
10
20
30
40
50
5
Hint
Sample Explanation
For sample , it can be proven that there is no speed that meets the requirements.
For sample , when , the times to reach supermarkets to are , , , , , all of which are even, so the requirement is satisfied. It can be proven that there is no faster valid speed.
This problem uses bundled testdata.
| Subtask ID | Score | ||
|---|---|---|---|
| Guaranteed | |||
For of the data, , . It is guaranteed that all inputs are positive integers.
Translated by ChatGPT 5