import numpy as np N = int(input()) y = list(map(int, input().split())) x = [i for i in range(N)] def least_squares(x, y): n = len(x) var_x = np.var(x) mu_x = np.mean(x) mu_y = np.mean(y) cov = sum((x-mu_x)*(y-mu_y)) / n a = cov / var_x b = mu_y - a*mu_x cost = sum((_y - a*_x - b) ** 2 for _x, _y in zip(x, y)) return a, b, cost a, b, c = least_squares(x, y) print(b, a) print(c)