VK Cup 2012 Qualification Round 1
D
Ice Sculptures
Codeforces
1300
原题
← CE →
翻译中…

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus $*n*$ ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular $*n*$-gon. They are numbered in clockwise order with numbers from 1 to $*n*$.

翻译中…

The site of the University has already conducted a voting that estimated each sculpture's characteristic of $*t*_{*i*}$ — the degree of the sculpture's attractiveness. The values of $*t*_{*i*}$ can be positive, negative or zero.

翻译中…

When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that:

翻译中…
  • the remaining sculptures form a regular polygon (the number of vertices should be between 3 and $*n*$),
  • the sum of the $*t*_{*i*}$ values of the remaining sculptures is maximized.
翻译中…

Help the Vice Rector to analyze the criticism — find the maximum value of $*t*_{*i*}$ sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.

翻译中…

Input

翻译中…

The first input line contains an integer $*n*$ ($3 ≤ *n* ≤ 20000$) — the initial number of sculptures. The second line contains a sequence of integers $*t*_{1}, *t*_{2}, ..., *t*_{*n*}$, $*t*_{*i*}$ — the degree of the $*i*$-th sculpture's attractiveness ($- 1000 ≤ *t*_{*i*} ≤ 1000$). The numbers on the line are separated by spaces.

翻译中…

Output

翻译中…

Print the required maximum sum of the sculptures' attractiveness.

翻译中…

Note

翻译中…

In the first sample it is best to leave every second sculpture, that is, leave sculptures with attractivenesses: 2, 4, 5 и 3.

翻译中…

样例

Input #1
8
1 2 -3 4 -5 5 2 3
Output #1
14
InputCopy OutputCopy
Input #2
6
1 -2 3 -4 5 -6
Output #2
9
InputCopy OutputCopy
Input #3
6
1 2 3 4 5 6
Output #3
21
InputCopy OutputCopy
题目信息
题号
158D
时间限制
3 s
内存限制
256 MB
标签
*special
暴力
数论

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