打印包含价格相等所需的最小秒数的唯一一行,如果不可能,则打印«-1»。
示例
Note
Consider the first example.
Suppose the third price decreases in the first second and become equal
12 rubles, then the first price decreases and becomes equal
9 rubles, and in the third second the third price decreases again and becomes equal
9 rubles. In this case all prices become equal
9 rubles in
3 seconds.
There could be other possibilities, but this minimizes the time needed for all prices to become equal. Thus the answer is
3.
In the second example we can notice that parity of first and second price is different and never changes within described process. Thus prices never can become equal.
In the third example following scenario can take place: firstly, the second price drops, then the third price, and then fourth price. It happens
999999999 times, and, since in one second only one price can drop, the whole process takes
999999999*3=2999999997 seconds. We can note that this is the minimum possible time.