#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> v;
int sum = 0;
void answer() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  if (N == 1) {
    cout << v[0];
  } else {
    for (int i = 0; i < K; i++) {
      sum += min(v[i], v[i + 1]);
      cout << sum << endl;
    }
    cout << sum << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  answer();
  return 0;
}
