#P52. [KBC004D] Math

[KBC004D] Math

Source

This problem is adapted from Long Long OJ. All rights reserved.

Attention

The memory limit for this problem is 8 MB.

Problem Description

Given an integer sequence a1ana_1\sim a_n of length nn, find the pair (x,y)(x,y) that minimizes the value of i=1n(x+iyai)2\sum\limits_{i=1}^{n}(x+iy-a_i)^2.

Input Format

The first line contains an integer nn, and the second line contains the sequence a1ana_1\sim a_n.

Output Format

Output a single line with two floating-point numbers xx and yy, with a relative or absolute error within 10310^{-3}.

Samples

20
-1711 5271 1865 -7326 7975 -4709 5564 5578 -121 -8285 -10084 902 3610 -4082 -8018 6737 6038 -621 5880 -958
-121.971429 31.286466

Data Range

Test Case ID n=n= Score
11 2020 1010
22 5×1055 \times 10^5 3030
33 10610^6 6060

The first test case is the sample.

For 100%100\% of the data, 1n1061 \le n \le 10^6 and ai109|a_i|\le 10^9.