#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,k,A[100010];

ll check(ll mid){
  int i=0;
  for(int j=0;j<k;j++){
    ll s=0;
    while(s+A[i]<=mid){
      s+=A[i];
      if(i>=n){return n;}
      i++;
    }
  }
  return i;
}


ll search(){
  ll left=0;
  ll right=100010*10000;
  ll mid;
  while(left<right){
    mid=(left+right)/2;
    if(check(mid)>=n){right=mid;}
    else{
      left=mid+1;
    }
  }
  return right;
}

int main(){
  cin>> n>>k;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cout << search()<<endl;
}
