Program Divide;
Uses Math;

Const
      MaxN=10000;

Var f: Text;
    n, k: LongInt;  //
    s: Array [0..MaxN] of LongInt;
    t: Array [1..MaxN] of LongInt;
    i, j, m, c: LongInt;

Begin
  {Input}
//  Assign(f, 'row.in'); Reset(f);
  Readln(n, k);
  s[0]:= 0;
  For i:= 1 To n Do Begin
    Read(c);
    s[i]:= s[i-1]+c;
    t[i]:= s[i];
  End;
//  Close(f);
  For m:= 2 To k Do Begin
    For i:= n DownTo m Do Begin
      c:= s[n]+1;
      For j:= m To i Do Begin
        c:= min (c, max(t[j-1], s[i]-s[j-1]));
      End;
      t[i]:= c;
    End;
  End;

  {Output}
//  Assign(f, 'row.out'); Rewrite(f);
  Writeln(t[n]);
  //Close(f);
End.
