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


#P????????°??¨??????????????¬??§??????Wi????????°?????????????????¢??°
def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans

low = 0
high = 100000 * 100000 # n * k????????§???
while low != high:
 mid = (low + high) // 2
 if howmany(mid) == n:
  high = mid
 else:
  low = mid + 1
print(str(low)) n,k = map(int, input().split()) n 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 WL = [int(input()) for i in range(n)] WL [int(input()) for i in range(n)] def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans howmany ans = 0 ans 0 truck = 1 truck 1 i = 0 i 0 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
  truck <= k and i <= n-1 truck <= k truck k i <= n-1 i n-1 n 1 rp = P rp P while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
   rp >= WL[i] rp WL[i] WL i ans += 1 ans 1 rp -= WL[i] rp WL[i] WL i i += 1 i 1 if i == n: break
   i == n i n truck += 1 truck 1 return ans ans P P low = 0 low 0 high = 100000 * 100000 high 100000 * 100000 100000 100000 while low != high:
 mid = (low + high) // 2
 if howmany(mid) == n:
  high = mid
 else:
  low = mid + 1 low != high low high mid = (low + high) // 2 mid (low + high) // 2 low + high low high 2 if howmany(mid) == n:
  high = mid
 else:
  low = mid + 1 howmany(mid) == n howmany(mid) howmany mid n high = mid high mid low = mid + 1 low mid + 1 mid 1 print(str(low)) print str(low) str low def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans howmany WL = [int(input()) for i in range(n)] [int(input()) for i in range(n)] WL n,k = map(int, input().split()) map(int, input().split()) n high = 100000 * 100000 100000 * 100000 high high = mid mid high low = mid + 1 mid + 1 low k = map(int, input().split()) map(int, input().split()) k low = 0 0 low mid = (low + high) // 2 (low + high) // 2 mid
n,k = map(int, input().split())
WL = [int(input()) for i in range(n)]


#P????????°??¨??????????????¬??§??????Wi????????°?????????????????¢??°
def howmany(P):
 ans = 0
 truck = 1
 i = 0
 while truck <= k and i <= n-1:
  rp = P
  while rp >= WL[i]:
   ans += 1
   rp -= WL[i]
   i += 1
   if i == n: break
  truck += 1
 return ans

low = 0
high = 100000 * 100000 # n * k????????§???
while low != high:
 mid = (low + high) // 2
 if howmany(mid) == n:
  high = mid
 else:
  low = mid + 1
print(str(low))