#include<stdio.h>
#define MAX 100001
typedef unsigned long long llong;
int datanum,k;
llong T[MAX];
int check(llong P){
  int i=0,j=0;
  for(j=0;j<k;j++){
    llong s = 0;
    while(s + T[i] <= P){
      s += T[i];
      i++;
      if(i == datanum)return datanum;
    }
  }
  return i;
}

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

void print(llong i){
  printf("%lld\n",i);
}

int main(){
  llong ans;
  int i;
  scanf("%d %d",&datanum,&k);
  for(i=0;i<datanum;i++)scanf("%lld",&T[i]);
  ans = solve();
  print(ans);
  return 0;
}

