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

left = 0
right = 100000 * 10000

def check(loaded_w):
  truck_num = 1
  tmp_w = 0
  i = 0
  while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
  return True

while left != right:
  mid = (left + right) // 2
  if check(mid):
    right = mid
  else:
    left = mid + 1
print(left) n, k = list(map(int, input().split(' '))) n list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w = [int(input()) for i in range(n)] w [int(input()) for i in range(n)] left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 def check(loaded_w):
  truck_num = 1
  tmp_w = 0
  i = 0
  while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
  return True check truck_num = 1 truck_num 1 tmp_w = 0 tmp_w 0 i = 0 i 0 while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
   i < n i n if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
     tmp_w + w[i] > loaded_w tmp_w + w[i] tmp_w w[i] w i loaded_w truck_num += 1 truck_num 1 tmp_w = 0 tmp_w 0 tmp_w += w[i] tmp_w w[i] w i i += 1 i 1 if truck_num > k:
      return False
   truck_num > k truck_num k return False False return True True loaded_w loaded_w while left != right:
  mid = (left + right) // 2
  if check(mid):
    right = mid
  else:
    left = mid + 1 left != right left right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 if check(mid):
    right = mid
  else:
    left = mid + 1 check(mid) check mid right = mid right mid left = mid + 1 left mid + 1 mid 1 print(left) print left w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w right = 100000 * 10000 100000 * 10000 right mid = (left + right) // 2 (left + right) // 2 mid def check(loaded_w):
  truck_num = 1
  tmp_w = 0
  i = 0
  while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
  return True def check(loaded_w):
  truck_num = 1
  tmp_w = 0
  i = 0
  while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
  return True check right = mid mid right k = list(map(int, input().split(' '))) list(map(int, input().split(' '))) k left = mid + 1 mid + 1 left n, k = list(map(int, input().split(' '))) list(map(int, input().split(' '))) n left = 0 0 left
n, k = list(map(int, input().split(' ')))
w = [int(input()) for i in range(n)]

left = 0
right = 100000 * 10000

def check(loaded_w):
  truck_num = 1
  tmp_w = 0
  i = 0
  while i < n:
    if tmp_w + w[i] > loaded_w:
      truck_num += 1
      tmp_w = 0
    else:
      tmp_w += w[i]
      i += 1
    if truck_num > k:
      return False
  return True

while left != right:
  mid = (left + right) // 2
  if check(mid):
    right = mid
  else:
    left = mid + 1
print(left)
