#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  int res = 0;
  int min = INT32_MAX;
  cin >> N >> K;
  vector<int> arr(N);
  for (int i = 0; i < N; ++i) {
    cin >> arr[i];
  }
  for (int i = 0; i <= N - K; i++) {
    min = arr[i];
    for (int j = 1; j < K; j++) {
      if (arr[i + j] < min) {
        min = arr[i + j];
      }
    }
    res += min;
  }
  cout << res;
  return 0;
}
