#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];


int check(llong p){
  int i=0;
  for(int 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 solve(){
  llong l=0;
  llong r=100000*10000;
  llong m;
  while(r-l>1){
    m=(l+r)/2;
    int v=check(m);
    if(v>=n) r=m;
    else l=m;
  }

  return r;
}


int main(){
  
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> T[i];
  llong ans =solve();
  cout << ans << endl;
}

