CF1098E.Fedya the Potter
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Fedya loves problems involving data structures. Especially ones about different queries on subsegments. Fedya had a nice array a1,a2,…an and a beautiful data structure. This data structure, given l and r , 1≤l≤r≤n , could find the greatest integer d , such that d divides each of al , al+1 , ..., ar .
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 bl+bl+1+…+br for given l and r , 1≤l≤r≤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 ⌊2k+1⌋ , 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 .
输入格式
First line contains a single integer n — number of elements in array a ( 1≤n≤50000 ).
Second line contains n integers a1,a2,…,an — elements of the array ( 1≤ai≤100000 ).
输出格式
Print a single integer — the lower median of array c .
输入输出样例
输入#1
2 6 3
输出#1
6
输入#2
2 8 8
输出#2
8
输入#3
5 19 16 2 12 15
输出#3
12
说明/提示
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 .