#include<stdio.h>
#define MAX 100000

typedef long long llong;

int n, k;

llong T[MAX];
 
int allCheck(llong P);
int allSolve();
 
int main(){

  int i;

  scanf("%d%d",&n,&k);

  for(i = 0;i < n;i ++)
    {
      scanf("%d",&T[i]);
    }
  llong ans = allSolve();

  printf("%d\n",ans);
 
  return 0;
}

int allCheck(llong P){

  int i = 0, j;

  for(j = 0;j < k;j ++)
    {
      llong s = 0;

      while(s + T[i] <= P)
	{
	  s += T[i];
	  i ++;
	  if(i == n) return n;
	}
    }
  return i;
}
 
int allSolve(){

  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  int v;

  while(right - left > 1){

    mid = (left + right) / 2;

    v = allCheck(mid);

    if(v >= n){
      right = mid;
    }
    
    else left = mid;
  }
 
  return right;
}