#include<stdio.h>

#define MAX 100000
#define PMAX MAX*10000
#define true 1
#define false 0

int n, k;
int minp=0;
int  w[MAX];

int minp_check(int P){
  int i, j;
  int sum;

  i = 0;
  for(j = 0; j < k; j++){
    sum = 0;
    while(sum + w[i] <= P){
      sum += w[i];
      i++;
      if(i == n){
        minp = P;
        return true;
      }
    }
  }

  return false;
}

void p_search(int left, int right){
  int mid;

  while(right - left > 1){
    mid = (left+right)/2;
    if(minp_check(mid) == true) return p_search(left, mid);
    else if(minp_check(mid) == false) return p_search(mid, right);
  }
}

int main(){
  int left = 0, right = PMAX;
  int i;

  scanf("%d %d", &n ,&k);
  for(i = 0; i < n; i++){
    scanf("%d", &w[i]);
  }

  p_search(left, right);

  printf("%d\n", minp);

  return 0;
}

