[n, k] = map(int, input().split(' '))
wi = list(map(int, [input() for i in range(n)]))

def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True

l = 0
r = sum(wi)
while l + 1 < r:
  p = int((l + r) / 2)
  if isAllocatable(p): r = p
  else: l = p
print(r)
 [n, k] = map(int, input().split(' ')) [n, k] n k map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' input() for i in range(n) for i in range(n) i range(n) range n for i in range(n) input() input wi = list(map(int, [input() for i in range(n)])) wi list(map(int, [input() for i in range(n)])) list map(int, [input() for i in range(n)]) map int [input() for i in range(n)] def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True isAllocatable kw, ki = 0, 1 kw 0 ki 1 for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
   w wi if w > p: return False
     w > p w p kw += w kw w if kw <= p: continue
     kw <= p kw p ki += 1 ki 1 if k < ki: return False
     k < ki k ki kw = w kw w return True True p p l = 0 l 0 r = sum(wi) r sum(wi) sum wi while l + 1 < r:
  p = int((l + r) / 2)
  if isAllocatable(p): r = p
  else: l = p l + 1 < r l + 1 l 1 r p = int((l + r) / 2) p int((l + r) / 2) int (l + r) / 2 l + r l r 2 if isAllocatable(p): r = p
  else: l = p isAllocatable(p) isAllocatable p print(r) print r l = 0 0 l p = int((l + r) / 2) int((l + r) / 2) p def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True isAllocatable wi = list(map(int, [input() for i in range(n)])) list(map(int, [input() for i in range(n)])) wi r = sum(wi) sum(wi) r
[n, k] = map(int, input().split(' '))
wi = list(map(int, [input() for i in range(n)]))

def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True

l = 0
r = sum(wi)
while l + 1 < r:
  p = int((l + r) / 2)
  if isAllocatable(p): r = p
  else: l = p
print(r)

