#include <bits/stdc++.h>
using namespace std;
int a[100009], b[100009], tree[300009], w;
int init(int s, int e, int node) {
  if (s == e) {
    tree[node] = a[s];
    return tree[node];
  }
  int m = (s + e) / 2;
  tree[node] = init(s, m, 2 * node) + init(m + 1, e, 2 * node + 1);
  return tree[node];
}
int query(int qs, int qe, int s, int e, int node) {
  if (qs > qe || s > qe || e < qs) return 0;
  if (s >= qs && e <= qe) return tree[node];
  int m = (s + e) / 2;
  return query(qs, qe, s, m, 2 * node) + query(qs, qe, m + 1, e, 2 * node + 1);
}
int update(int qs, int qe, int s, int e, int node) {
  if (s > qe || e < qs) return tree[node];
  if (s == qs && e == qe && s == e) return tree[node] = a[s];
  int m = (s + e) / 2;
  return tree[node] = update(qs, qe, s, m, 2 * node) +
                      update(qs, qe, m + 1, e, 2 * node + 1);
}
int bin(int s, int e) {
  while (s <= e) {
    int m = (s + e) / 2;
    if (query(m + 1, e, 1, w - 1, 1))
      s = m + 1;
    else if (query(m, m, 1, w - 1, 1))
      return m;
    else
      e = m - 1;
  }
  return 0;
}
int main() {
  int k, i, ans, cur, pos;
  cin >> w >> k;
  for (i = 1; i < w; i++) cin >> a[i];
  init(1, w - 1, 1);
  for (i = 1; i <= k; i++) {
    b[i] = a[i];
    a[i] = 0;
  }
  for (i = 1; i < w; i++) {
    if (b[i] == 0) continue;
    pos = bin(i + 1, i + k);
    if (pos == 0) continue;
    if (b[i] <= a[pos]) {
      b[pos] += b[i];
      a[pos] -= b[i];
      b[i] = 0;
      update(pos, pos, 1, w - 1, 1);
    } else {
      b[pos] += a[pos];
      b[i] -= a[pos];
      a[pos] = 0;
      update(pos, pos, 1, w - 1, 1);
      i--;
    }
  }
  ans = 0;
  for (i = w - 1; i >= w - k; i--) ans += b[i];
  cout << ans << endl;
}
