import numpy as np INF = 10 ** 10 N = int(input()) X = np.arange(N,dtype = np.int64) Y = np.array(input().split(),dtype = np.int64) median_Y = Y.sum()/N median_X = (N - 1)/2 Sx = ((X - median_X) ** 2).sum()/N Sxy = ((X - median_X)*(Y - median_Y)).sum()/N b1 = Sxy/Sx b0 = median_Y - median_X*b1 cost = ((Y - b0 - b1*X)**2).sum() print(b0,b1) print(cost)