quantity, num = list(map(int, input().split()))
weights = list(map(int, [input() for _ in range(quantity)]))

def truck_num(max_load, weights):
  num = 1
  tmp = 0
  for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
  return num


left = max(weights)
right = 100000 * 10000

while left != right:
  mid = (left + right) // 2
  x = truck_num(mid, weights)
  if x <= num:
    right = mid
  else:
    left = mid + 1

ans = left
print(ans) quantity, num = list(map(int, input().split())) quantity list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split num input() for _ in range(quantity) for _ in range(quantity) _ range(quantity) range quantity for _ in range(quantity) input() input weights = list(map(int, [input() for _ in range(quantity)])) weights list(map(int, [input() for _ in range(quantity)])) list map(int, [input() for _ in range(quantity)]) map int [input() for _ in range(quantity)] def truck_num(max_load, weights):
  num = 1
  tmp = 0
  for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
  return num truck_num num = 1 num 1 tmp = 0 tmp 0 for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
   w weights if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
   tmp + w <= max_load tmp + w tmp w max_load tmp += w tmp w tmp = w tmp w num += 1 num 1 return num num max_load max_load weights weights left = max(weights) left max(weights) max weights right = 100000 * 10000 right 100000 * 10000 100000 10000 while left != right:
  mid = (left + right) // 2
  x = truck_num(mid, weights)
  if x <= num:
    right = mid
  else:
    left = mid + 1 left != right left right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 x = truck_num(mid, weights) x truck_num(mid, weights) truck_num mid weights if x <= num:
    right = mid
  else:
    left = mid + 1 x <= num x num right = mid right mid left = mid + 1 left mid + 1 mid 1 ans = left ans left print(ans) print ans def truck_num(max_load, weights):
  num = 1
  tmp = 0
  for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
  return num def truck_num(max_load, weights):
  num = 1
  tmp = 0
  for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
  return num truck_num right = mid mid right x = truck_num(mid, weights) truck_num(mid, weights) x weights = list(map(int, [input() for _ in range(quantity)])) list(map(int, [input() for _ in range(quantity)])) weights left = mid + 1 mid + 1 left quantity, num = list(map(int, input().split())) list(map(int, input().split())) quantity mid = (left + right) // 2 (left + right) // 2 mid ans = left left ans left = max(weights) max(weights) left right = 100000 * 10000 100000 * 10000 right num = list(map(int, input().split())) list(map(int, input().split())) num
quantity, num = list(map(int, input().split()))
weights = list(map(int, [input() for _ in range(quantity)]))

def truck_num(max_load, weights):
  num = 1
  tmp = 0
  for w in weights:
    if tmp + w <= max_load:
      tmp += w
    else:
      tmp = w
      num += 1
  return num


left = max(weights)
right = 100000 * 10000

while left != right:
  mid = (left + right) // 2
  x = truck_num(mid, weights)
  if x <= num:
    right = mid
  else:
    left = mid + 1

ans = left
print(ans)
