import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextLong(); } long xy = 0; long x = 0; long y = 0; long x2 = 0; for(int i = 0; i < n; i++) { xy += (i * a[i]); x += i; y += a[i]; x2 += (i * i); } double A = (double)(n * xy - x * y) / (double)(n * x2 - x * x); double B = (double)(x2 * y - xy * x) / (double)(n * x2 - x * x); double c = 0; for(int i = 0; i < n; i++) { double t = A * (double)i + B; c += ((double)((a[i] - t) * (a[i] - t))); } System.out.println(B + " " + A); System.out.println(c); } }