n, k = list(map(int,input().split()))
w = list()
for _ in range(n):
  w.append(int(input()))

w_sum = sum(w)



def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v


def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r

res = search(n, 0, 10000 * 100000, f)
print(res)

 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 w = list() w list() list for _ in range(n):
  w.append(int(input())) _ range(n) range n w.append(int(input())) w.append w append int(input()) int input() input w_sum = sum(w) w_sum sum(w) sum w def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v f v = 0 v 0 for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
   _ range(k) range k s = 0 s 0 while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
   s + w[v] <= p s + w[v] s w[v] w v p s += w[v] s w[v] w v v += 1 v 1 if v == n:
        return v
   v == n v n return v v return v v p p def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r search while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
   r - l > 1 r - l r l 1 m = (l + r) // 2 m (l + r) // 2 l + r l r 2 v = f(m) v f(m) f m if  v >= n:
      r = m 
    else:
      l = m
   v >= n v n r = m r m l = m l m return r r a a l l r r f f res = search(n, 0, 10000 * 100000, f) res search(n, 0, 10000 * 100000, f) search n 0 10000 * 100000 10000 100000 f print(res) print res k = list(map(int,input().split())) list(map(int,input().split())) k w = list() list() w w_sum = sum(w) sum(w) w_sum def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r search res = search(n, 0, 10000 * 100000, f) search(n, 0, 10000 * 100000, f) res n, k = list(map(int,input().split())) list(map(int,input().split())) n def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v f
n, k = list(map(int,input().split()))
w = list()
for _ in range(n):
  w.append(int(input()))

w_sum = sum(w)



def f(p):
  v = 0
  for _ in range(k):
    s = 0
    while s + w[v] <= p:
#      print("add", w[v])
      s += w[v]
      v += 1
      if v == n:
        return v
  return v


def search(a, l, r, f):
  while r - l > 1 :
    m = (l + r) // 2
    v = f(m)
    if  v >= n:
      r = m 
    else:
      l = m
  return r

res = search(n, 0, 10000 * 100000, f)
print(res)


