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

def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num

P_lb, P_min = 0, max(w)*(n//k + 1)
while P_min - P_lb > 1:
  P_mid = (P_lb + P_min) // 2
  if n_loads(P_mid) < n:
    P_lb = P_mid
  else:
    P_min = P_mid
print(P_min) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input w = [int(input()) for _ in range(n)] w [int(input()) for _ in range(n)] def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num n_loads num = 0 num 0 for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
   _ range(k) range k w_sum = 0 w_sum 0 while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
   num < n and w_sum + w[num] <= P num < n num n w_sum + w[num] <= P w_sum + w[num] w_sum w[num] w num P w_sum += w[num] w_sum w[num] w num num += 1 num 1 return num num P P P_lb, P_min = 0, max(w)*(n//k + 1) P_lb 0 P_min max(w)*(n//k + 1) max(w) max w n//k + 1 n//k n k 1 while P_min - P_lb > 1:
  P_mid = (P_lb + P_min) // 2
  if n_loads(P_mid) < n:
    P_lb = P_mid
  else:
    P_min = P_mid P_min - P_lb > 1 P_min - P_lb P_min P_lb 1 P_mid = (P_lb + P_min) // 2 P_mid (P_lb + P_min) // 2 P_lb + P_min P_lb P_min 2 if n_loads(P_mid) < n:
    P_lb = P_mid
  else:
    P_min = P_mid n_loads(P_mid) < n n_loads(P_mid) n_loads P_mid n P_lb = P_mid P_lb P_mid P_min = P_mid P_min P_mid print(P_min) print P_min w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num n_loads P_min = 0, max(w)*(n//k + 1) max(w)*(n//k + 1) P_min n, k = map(int, input().split()) map(int, input().split()) n P_lb, P_min = 0, max(w)*(n//k + 1) 0 P_lb P_min = P_mid P_mid P_min P_mid = (P_lb + P_min) // 2 (P_lb + P_min) // 2 P_mid k = map(int, input().split()) map(int, input().split()) k P_lb = P_mid P_mid P_lb
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def n_loads(P):
  num = 0
  for _ in range(k):
    w_sum = 0
    while num < n and w_sum + w[num] <= P:
      w_sum += w[num]
      num += 1
  return num

P_lb, P_min = 0, max(w)*(n//k + 1)
while P_min - P_lb > 1:
  P_mid = (P_lb + P_min) // 2
  if n_loads(P_mid) < n:
    P_lb = P_mid
  else:
    P_min = P_mid
print(P_min)
