import java.io.*; import java.util.*; public class Main_yukicoder731 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } long aa = 0, bb = 0, cc = 0, dd = 0, ee = 0, ff = 0; for (int i = 0; i < n; i++) { aa += i * i; bb += i; cc += i; dd += 1; ee += i * a[i]; ff += a[i]; } if (aa * dd - bb * cc == 0) { } else { double xx = (double)(ee * dd - bb * ff) / (aa * dd - bb * cc); double yy = (double)(aa * ff - cc * ee) / (aa * dd - bb * cc); double cost = 0; for (int i = 0; i < n; i++) { double tmp = xx * i + yy - a[i]; cost += tmp * tmp; } pr.printf("%.7f %.7f\n", yy, xx); pr.printf("%.7f\n", cost); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())); pr = new Printer(System.out); solve(); // pr.close(); pr.flush(); // sc.close(); } static String INPUT = null; private static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }