ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

USU Open Personal Contest 2011

About     Problems     Submit solution     Judge status     Standings
Contest is over

I. Approximation by a Progression

Time limit: 0.5 second
Memory limit: 64 MB
Your are given a sequence of integers a1, …, an. Find an arithmetic progression b1, …, bn for which the value ∑(aibi)2 is minimal. The elements of the progression can be non-integral.

Input

The first line contains the number n of elements in the sequence (2 ≤ n ≤ 104). In the second line you are given the integers a1, …, an; their absolute values do not exceed 104.

Output

Output two numbers separated with a space: the first term of the required arithmetic progression and its difference, with an absolute or relative error of at most 10−6. It is guaranteed that the answer is unique for all input data.

Samples

inputoutput
4
0 6 10 15
0.400 4.900
4
-2 -2 -2 -2
-2 0
Problem Author: Alex Samsonov
Problem Source: XII USU Open Personal Contest (March 19, 2011)
To submit the solution for this problem go to the Problem set: 1828. Approximation by a Progression