#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umin(T &a, T b) {
  a = min(a, b);
}
template <class T>
inline void umax(T &a, T b) {
  a = max(a, b);
}
const int INF = 0x3f3f3f3f;
long long mod = 1e9 + 7;
const int N = 100005;
int a[N];
int ans = 0;
int m, n;
int b[N], c[N];
set<int> se;
void check(int u) {
  if (a[u] == 0) {
    se.erase(u);
    int e1 = c[u], e2 = b[u];
    b[e1] = e2;
    c[e2] = e1;
  }
}
int ok;
void dfs(int u, int g) {
  if (ok == 0) return;
  if (u + m >= n) {
    a[u] -= g;
    ans += g;
    return;
  }
  int x = *se.upper_bound(u + m);
  x = c[x];
  if (x <= u) {
    ok = 0;
    return;
  }
  while (x > u && g > 0) {
    int tmp = min(a[x], g);
    g -= tmp;
    a[u] -= tmp;
    check(u);
    dfs(x, tmp);
    x = c[x];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int last = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > 0) {
      se.insert(i);
      b[last] = i;
      c[i] = last;
      last = i;
    }
  }
  se.insert(n);
  b[last] = n;
  c[n] = last;
  ok = 1;
  for (int i = m; i >= 1 && ok; i--) {
    dfs(i, a[i]);
  }
  printf("%d\n", ans);
  return 0;
}
