Stone Skipping (SUJEBI)

For each step size d, sum the cells at multiples of d and pick the d with the largest sum, printing 0 0 if that sum is not positive.

Medium5MathBrute forcePrefix sumImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

A sharp change in the climate let invasive species spread through many rivers of Daegwak. The government discussed the problem and settled on the Flat Dumpling Plan: skip a stone across a river and wipe out the invasive species in the cells the stone touches.

The river picked for the plan has width LL, and the river is modeled as LL consecutive cells numbered 1 through LL. The environment ministry scored every cell by how dangerous the species living there is. Some cells hold native species, so a score can be negative.

Throwing two or more stones makes your arm hurt, so exactly one stone is thrown. Depending on the power of the throw, the stone bounces at a fixed interval dd (1dL1 \le d \le L), passing over cell dd, then cell 2d2d, and so on up to cell L/dd\lfloor L/d \rfloor d. Find the natural number dd that maximizes the sum of the scores of the cells the stone passes over.

Input

The first line contains the river width LL. LL is an integer between 1 and 1,000,000.

The second line contains the scores of the LL cells in order starting from cell 1, separated by spaces. Every score is an integer between -50,000 and 50,000.

Output

Print the dd that maximizes the sum of the scores and that maximum sum, separated by a space. If several values of dd reach the maximum, print the smallest one. If the maximum sum is 0 or less, running the plan is not worth it, so print 0 0.