#include using namespace std; using ld = long double; int main() { cout << fixed << setprecision(10); int n, m; cin >> n >> m; vector c(n); for (int i = 1; i < n - 1; i++) { cin >> c[i]; } vector dp(n); for (int i = n - 1; i >= 0; i--) { if (n - 1 <= i + m) { dp[i] = c[i]; } else { for (int j = 1; j <= m; j++) { dp[i] += (dp[i + j] + c[i]) / m; } } } cout << dp[0] << endl; return 0; }