#include <stdio.h>
int check(long long);
int solve(void);

int n,k;
long long W[100000];

int main(){
  int i,P;
  scanf("%d %d",&n,&k);
  for(i = 0; i < n; i++){
  scanf("%d",&W[i]);
}
  P = solve();
  printf("%d\n",P);
  return 0;
}
int check(long long P){
  int i = 0,j;
  long long sum;
  for(j = 0; j < k; j++){
    sum=0;
    while(sum + W[i] <= P){
      sum += W[i];
      i++;
      if(i == n) return n;
    }
  }
}

int solve(void){
  long long left = 0;
  long long right = 100000 * 10000;
  long long mid;
  int v;
  while(right - left > 1){
    mid = (left + right) / 2;
    v = check(mid);
    if(v >= n) right = mid;
    else left = mid;
  }
  return right;
}