#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, inf = 1e9 + 7;
int n, k, i, j;
int A[N], C[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, a, b, ans = 0;
  cin >> n >> k;
  for (i = 1; i < n; i++) cin >> A[i];
  C[0] = inf;
  A[n] = inf;
  i = 1;
  j = 0;
  while (i <= n) {
    a = min(A[i], C[j]);
    C[j] -= a;
    C[i] += a;
    A[i] -= a;
    if (A[i] == 0) i++;
    if (C[j] == 0) j++;
    while (i <= n && j >= i) i++;
    if (i - j > k) j++;
  }
  cout << C[n];
}
