Codeforces Round 530 (Div. 1)
E
Fedya the Potter
Codeforces
3400
原题
← DF →
翻译中…

Fedya loves problems involving data structures. Especially ones about different queries on subsegments. Fedya had a nice array $a_1, a_2, \ldots a_n$ and a beautiful data structure. This data structure, given $l$ and $r$, $1 \le l \le r \le n$, could find the greatest integer $d$, such that $d$ divides each of $a_l$, $a_{l+1}$, ..., $a_{r}$.

翻译中…

Fedya really likes this data structure, so he applied it to every non-empty contiguous subarray of array $a$, put all answers into the array and sorted it. He called this array $b$. It's easy to see that array $b$ contains $n(n+1)/2$ elements.

翻译中…

After that, Fedya implemented another cool data structure, that allowed him to find sum $b_l + b_{l+1} + \ldots + b_r$ for given $l$ and $r$, $1 \le l \le r \le n(n+1)/2$. Surely, Fedya applied this data structure to every contiguous subarray of array $b$, called the result $c$ and sorted it. Help Fedya find the lower median of array $c$.

翻译中…

Recall that for a sorted array of length $k$ the lower median is an element at position $\lfloor \frac{k + 1}{2} \rfloor$, if elements of the array are enumerated starting from $1$. For example, the lower median of array $(1, 1, 2, 3, 6)$ is $2$, and the lower median of $(0, 17, 23, 96)$ is $17$.

翻译中…

Input

翻译中…

First line contains a single integer $n$ — number of elements in array $a$ ($1 \le n \le 50\,000$).

翻译中…

Second line contains $n$ integers $a_1, a_2, \ldots, a_n$ — elements of the array ($1 \le a_i \le 100\,000$).

翻译中…

Output

翻译中…

Print a single integer — the lower median of array $c$.

翻译中…

Note

翻译中…

In the first sample array $b$ is equal to ${3, 3, 6}$, then array $c$ is equal to ${3, 3, 6, 6, 9, 12}$, so the lower median is $6$.

翻译中…

In the second sample $b$ is ${8, 8, 8}$, $c$ is ${8, 8, 8, 16, 16, 24}$, so the lower median is $8$.

翻译中…

样例

Input #1
2
6 3
Output #1
6
InputCopy OutputCopy
Input #2
2
8 8
Output #2
8
InputCopy OutputCopy
Input #3
5
19 16 2 12 15
Output #3
12
InputCopy OutputCopy
题目信息
题号
1098E
时间限制
2.5 s
内存限制
256 MB
标签
二分
模拟
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。