# 2654. Median

This problem is easy. You are giving $N$ numbers, and you are going to find the Median of them. Median is the number that separates the higher half the numbers given from the lower half.

### 输入格式

There are some cases. Process to the end of file

Each case give as $N,A,X_0,B,M$ separates by a single space, and you are going to generate the numbers as follow:

$X_i = (X_{i-1} \cdot A + B) \bmod M$

$N$ would be less than $1~000~000$. Both $A, B, M, X_i$ would be a positive number less than $40000$.

### 输出格式

Output the number which is the median of the sequence in one line. If $N$ is even,you should output the second of the two medians.

### 样例

Input
5 73 5 97 43

Output
25


35 人解决，54 人已尝试。

66 份提交通过，共有 285 份提交。

5.0 EMB 奖励。