#B4192. Determining the Contest Cutoff Score

    ID: 11849 Type: Default 1000ms 256MiB

Determining the Contest Cutoff Score

Determining the Contest Cutoff Score

During a contest, each participant is assigned a score $s$. It is given that there are $c_1$ participants with score $1$, $c_2$ participants with score $2$, ..., and $c_m$ participants with score $m$. Your task is to choose a cutoff score $k$ such that the number of participants scoring not less than $k$ (denoted as $n_1$) and the number scoring less than $k$ (denoted as $n_2$) both fall within the range $[x, y]$, i.e.,

$x \leq n_1 \leq y$ and $x \leq n_2 \leq y$.

inputFormat

The first line contains three integers $m$, $x$, and $y$, where $m$ ($1 \leq m \leq 10^5$) denotes the maximum score, and $[x, y]$ is the required range for the counts.

The second line contains $m$ integers: $c_1, c_2, \dots, c_m$, where $c_i$ represents the number of participants who scored $i$.

outputFormat

Output a single integer $k$ ($1 \leq k \leq m$) which is a valid cutoff score such that the number of participants scoring not less than $k$ is between $x$ and $y$, and the number scoring less than $k$ is also between $x$ and $y$. If there are multiple valid answers, output any one of them. If no valid cutoff exists, output -1.

sample

5 2 5
1 2 3 4 5
4

</p>