#include <bits/stdc++.h>
using namespace std;
int maxSum(int arr[], int n, int k) {
  if (n < k) {
    cout << "Invalid";
    return -1;
  }
  int res = 0;
  for (int i = 0; i < k; i++) res += arr[i];
  int curr_sum = res;
  for (int i = k; i < n; i++) {
    curr_sum += arr[i] - arr[i - k];
    res = min(res, curr_sum);
  }
  return res;
}
int main() {
  int x, y;
  cin >> x;
  cin >> y;
  int arr[x];
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
  }
  int n = sizeof(arr) / sizeof(arr[0]);
  cout << maxSum(arr, n, y);
  return 0;
}
