Beats
题号:NC295122
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Colin loves music but cannot catch the rhythm well, especially when counting beats! After hard research on music theory, Colin found a hidden theorem: There won't be a note crossing the boundary between the beats for modern songs.

To simplify the problem, we assume that a modern song consists of several sequential notes whose lengths are l_1,l_2,\cdots,l_n milliseconds. The notes will be played one by one, which means the song will start playing the first note at the time 0, and the second note at the beginning of the l_1+1 milliseconds, and the third note at the beginning of the l_1+l_2+1 milliseconds, and so on.

If the length of the beat is L milliseconds, then there should not exist any note that is playing but not starting to play at the beginning of the kL milliseconds, for any non-negative integer k. Formally, there should not exist any note i such that \sum_{j=1}^{i-1} l_j< kL but \sum_{j=1}^il_j>kL for any non-negative integer k.

Now Colin has received a new song from Eva, and he wants to practice counting beats before he sings for Eva. To challenge himself, Colin wants to find the smallest possible length of a beat, such that it satisfies the theorem. Can you help him?

输入描述:

The first line contains a single integer n~(1\le n\le 2\times 10^5), representing the number of notes in the song. 

The second line contains n integers l_1,l_2,\cdots,l_n~(1\le l_i\le 10^9), representing the length of each note.

输出描述:

Output a single integer, representing the minimum possible length of a beat.
示例1

输入

复制
5
1 2 3 6 5

输出

复制
6
示例2

输入

复制
5
1 2 3 4 5

输出

复制
10