# coding:utf-8
n, k = map(int,raw_input().split())
ws = []
for _ in xrange(n):
  ws.append(int(raw_input()))

def possible_put_p(p):
  # P??\?????????????????????????????????
  current = 1
  weight = 0
  for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

  if current <= k:
    return True
  else:
    return False

low = max(ws)
high = sum(ws)
while(high - low > 0):
  mid = (low + high) / 2
  if(possible_put_p(mid)):
    high = mid
  else:
    low = mid + 1

print high n, k = map(int,raw_input().split()) n map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split k ws = [] ws [] for _ in xrange(n):
  ws.append(int(raw_input())) _ xrange(n) xrange n ws.append(int(raw_input())) ws.append ws append int(raw_input()) int raw_input() raw_input def possible_put_p(p):
  # P??\?????????????????????????????????
  current = 1
  weight = 0
  for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

  if current <= k:
    return True
  else:
    return False possible_put_p current = 1 current 1 weight = 0 weight 0 for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

   w ws if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

   weight + w <= p weight + w weight w p weight += w weight w current += 1 current 1 if current > k:
        return False
       current > k current k return False False weight = w weight w if current <= k:
    return True
  else:
    return False current <= k current k return True True return False False p p low = max(ws) low max(ws) max ws high = sum(ws) high sum(ws) sum ws while(high - low > 0):
  mid = (low + high) / 2
  if(possible_put_p(mid)):
    high = mid
  else:
    low = mid + 1 high - low > 0 high - low high low 0 mid = (low + high) / 2 mid (low + high) / 2 low + high low high 2 if(possible_put_p(mid)):
    high = mid
  else:
    low = mid + 1 possible_put_p(mid) possible_put_p mid high = mid high mid low = mid + 1 low mid + 1 mid 1 print n, k = map(int,raw_input().split()) map(int,raw_input().split()) n k = map(int,raw_input().split()) map(int,raw_input().split()) k low = mid + 1 mid + 1 low ws = [] [] ws low = max(ws) max(ws) low mid = (low + high) / 2 (low + high) / 2 mid high = sum(ws) sum(ws) high high = mid mid high def possible_put_p(p):
  # P??\?????????????????????????????????
  current = 1
  weight = 0
  for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

  if current <= k:
    return True
  else:
    return False def possible_put_p(p):
  # P??\?????????????????????????????????
  current = 1
  weight = 0
  for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

  if current <= k:
    return True
  else:
    return False possible_put_p
# coding:utf-8
n, k = map(int,raw_input().split())
ws = []
for _ in xrange(n):
  ws.append(int(raw_input()))

def possible_put_p(p):
  # P??\?????????????????????????????????
  current = 1
  weight = 0
  for w in ws:
    if weight + w <= p:
      weight += w
    else:
      current += 1
      if current > k:
        return False
      weight = w

  if current <= k:
    return True
  else:
    return False

low = max(ws)
high = sum(ws)
while(high - low > 0):
  mid = (low + high) / 2
  if(possible_put_p(mid)):
    high = mid
  else:
    low = mid + 1

print high