N = gets.to_i A = gets.split.map(&:to_i) P = [] A.each_with_index do |y, x| P << [x, y] end a = Rational( N * P.map { |x, y| x * y }.sum - P.map(&:first).sum * P.map(&:last).sum, N * P.map { |x, _| x ** 2 }.sum - P.map(&:first).sum ** 2 ) b = Rational( P.map { |x, _| x ** 2 }.sum * P.map(&:last).sum - P.map { |x, y| x * y }.sum * P.map(&:first).sum, N * P.map { |x, _| x ** 2 }.sum - P.map(&:first).sum ** 2 ) puts [b.to_f.round(12), a.to_f.round(12)].join(' ') puts A.map.with_index { |v, x| ((a * x + b) - v) ** 2 }.sum.to_f.round(12)