N = int(input()) src = list(map(int,input().split())) mu_x = (N-1) / 2 mu_y = sum(src) / N sq_sigma_x = 0 for x in range(N): sq_sigma_x += (x - mu_x)**2 sq_sigma_x /= N e_xy = sum([x*y for x,y in enumerate(src)]) / N cov = e_xy - mu_x*mu_y d = cov / sq_sigma_x bi = mu_y - d*mu_x cost = 0 for i,a in enumerate(src): cost += (a - (bi+i*d))**2 print(bi,d) print(cost)