import numpy as np n = int(input()) a = list(map(int,input().split())) su1 = (sum(a)*2) b1 = n*2 d1 = (0+2*(n-1))*n//2 su2 = 0 b2 = 0 d2 = 0 for i in range(n): su2 += a[i] * (i)*2 b2 += (i)*2 d2 += ((i)**2)*2 kake = np.array([[b1,d1],[b2,d2]]) ans = np.array([su1,su2]) ans = np.dot(np.linalg.inv(kake),ans) print(ans[0],ans[1]) kota = 0 for i in range(n): kota += (a[i]-ans[0]-ans[1]*i)**2 print(kota)