//================================= // Created on: 2018/09/07 21:23:40 //================================= #include #define show(x) std::cerr << #x << " = " << x << std::endl using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll MOD = 1000000007LL; template constexpr T INF = std::numeric_limits::max() / 10; std::mt19937 mt{std::random_device{}()}; int main() { ll N; std::cin >> N; ld xy = 0, y = 0; std::vector a(N); for (ll i = 0; i < N; i++) { std::cin >> a[i]; y += a[i], xy += i * a[i]; } const ld x = N * (N - 1) / 2, xx = N * (N - 1) * (2 * N - 1) / 6; const ld d = (N * xy - x * y) / (N * xx - x * x), b1 = (xx * y - xy * x) / (N * xx - x * x); std::cout << std::fixed << std::setprecision(15) << b1 << " " << d << std::endl; ld c = 0; for (ll i = 0; i < N; i++) { const ld D = (d * i + b1 - a[i]); c += D * D; } std::cout << c << std::endl; return 0; }