#!/usr/bin/python
# -*- coding:utf-8 -*-

load_num, track_num = list(map(int, input().split(" ")))

loads = list()
for _ in range(load_num):
    loads.append(int(input()))

P = 10000 * 100000

def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False


def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right

print(binary_search(P)) load_num, track_num = list(map(int, input().split(" "))) load_num list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " track_num loads = list() loads list() list for _ in range(load_num):
    loads.append(int(input())) _ range(load_num) range load_num loads.append(int(input())) loads.append loads append int(input()) int input() input P = 10000 * 100000 P 10000 * 100000 10000 100000 def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False isMeet i = 0 i 0 for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
     _ range(track_num) range track_num sum = 0 sum 0 while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
     sum + loads[i] <= p sum + loads[i] sum loads[i] loads i p sum += loads[i] sum loads[i] loads i i += 1 i 1 if i == load_num:
                return True
     i == load_num i load_num return True True return False False p p def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right binary_search left = 0 left 0 right = P right P while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
     right - left > 0 right - left right left 0 mid = int((left+right)/2) mid int((left+right)/2) int (left+right)/2 left+right left right 2 if isMeet(mid):
            right = mid
        else:
            left = mid + 1
     isMeet(mid) isMeet mid right = mid right mid left = mid + 1 left mid + 1 mid 1 return right right P P print(binary_search(P)) print binary_search(P) binary_search P track_num = list(map(int, input().split(" "))) list(map(int, input().split(" "))) track_num load_num, track_num = list(map(int, input().split(" "))) list(map(int, input().split(" "))) load_num def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right binary_search loads = list() list() loads P = 10000 * 100000 10000 * 100000 P def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False isMeet
#!/usr/bin/python
# -*- coding:utf-8 -*-

load_num, track_num = list(map(int, input().split(" ")))

loads = list()
for _ in range(load_num):
    loads.append(int(input()))

P = 10000 * 100000

def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False


def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right

print(binary_search(P))