import numpy as np N = int(input()) y = list(map(int, input().split())) x = [i for i in range(N)] a, b = np.polyfit(x, y, 1) c = sum((_y - a*_x - b) ** 2 for _x, _y in zip(x, y)) print(b, a) print(c)