Program Divide;

Const MaxN=10000;

Var f: Text;
    n, k: LongInt;  //
    s: Array [1..MaxN] of LongInt;
    i: LongInt;
    l, c, r, count, sum: LongInt;

Begin
  {Input}
//  Assign(f, 'row.in'); Reset(f);
  Readln(n, k);
  r:= 0;
  l:= 0;
  For i:= 1 To n Do Begin
    Read(s[i]);
    Inc(r, s[i]);
    If s[i]>l Then Begin
      l:= s[i];
    End;
  End;
//  Close(f);

  While l<r Do Begin
    c:= (l+r) div 2;
    count:= 0;
    i:= 0;
    Repeat
      sum:= 0;
      Repeat
        Inc(i);
        Inc(sum, s[i]);
      Until (i=n) or (sum+s[i+1]>c);
      Inc(count);
    Until i=n;
    If count<=k Then Begin
      r:= c;
    End
    Else Begin
      l:= c+1;
    End;
  End;


//  Assign(f, 'row.out'); Rewrite(f);
  Writeln(r);
//  Close(f);
End.
