#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int a[n];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int b[n];
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j < k; j++) {
      sum += a[j];
    }
    b[i] = sum;
  }
  int min = b[0];
  for (int i = 0; i < n; i++) {
    if (b[i] <= min) min = b[i];
  }
  cout << min;
  return 0;
}
