if __name__ == '__main__':
    import sys
    input = sys.stdin.readline



    n, k = map(int, input().split())

    ww = [0]*n
    for i in range(n):
        ww[i] = int(input())

    max_w = 10000

    max_p = max_w*n
    min_p = 0


    def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

    while min_p != max_p:
        mid = (max_p + min_p)//2
        if number_of_track(mid) <= k:
            max_p = mid
        else:
            min_p = mid+1
    print(max_p)
 if __name__ == '__main__':
    import sys
    input = sys.stdin.readline



    n, k = map(int, input().split())

    ww = [0]*n
    for i in range(n):
        ww[i] = int(input())

    max_w = 10000

    max_p = max_w*n
    min_p = 0


    def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

    while min_p != max_p:
        mid = (max_p + min_p)//2
        if number_of_track(mid) <= k:
            max_p = mid
        else:
            min_p = mid+1
    print(max_p) __name__ == '__main__' __name__ '__main__' import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k ww = [0]*n ww [0]*n [0] 0 n for i in range(n):
        ww[i] = int(input())

     i range(n) range n ww[i] = int(input()) ww[i] ww i int(input()) int input() input max_w = 10000 max_w 10000 max_p = max_w*n max_p max_w*n max_w n min_p = 0 min_p 0 def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

     number_of_track ans = 1 ans 1 sum_w = 0 sum_w 0 for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
         w ww if w > p:
                return n+1
             w > p w p return n+1 n+1 n 1 if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
         sum_w + w > p sum_w + w sum_w w p ans += 1 ans 1 sum_w = w sum_w w sum_w += w sum_w w return ans ans p p while min_p != max_p:
        mid = (max_p + min_p)//2
        if number_of_track(mid) <= k:
            max_p = mid
        else:
            min_p = mid+1
     min_p != max_p min_p max_p mid = (max_p + min_p)//2 mid (max_p + min_p)//2 max_p + min_p max_p min_p 2 if number_of_track(mid) <= k:
            max_p = mid
        else:
            min_p = mid+1
     number_of_track(mid) <= k number_of_track(mid) number_of_track mid k max_p = mid max_p mid min_p = mid+1 min_p mid+1 mid 1 print(max_p) print max_p min_p = 0 0 min_p n, k = map(int, input().split()) map(int, input().split()) n def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

     def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

     number_of_track max_w = 10000 10000 max_w mid = (max_p + min_p)//2 (max_p + min_p)//2 mid k = map(int, input().split()) map(int, input().split()) k input = sys.stdin.readline sys.stdin.readline input max_p = max_w*n max_w*n max_p ww = [0]*n [0]*n ww max_p = mid mid max_p min_p = mid+1 mid+1 min_p
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline



    n, k = map(int, input().split())

    ww = [0]*n
    for i in range(n):
        ww[i] = int(input())

    max_w = 10000

    max_p = max_w*n
    min_p = 0


    def number_of_track(p):
        ans = 1
        sum_w = 0
        for w in ww:
            if w > p:
                return n+1
            if sum_w + w > p:
                ans += 1
                sum_w = w
            else:
                sum_w += w
        return ans

    while min_p != max_p:
        mid = (max_p + min_p)//2
        if number_of_track(mid) <= k:
            max_p = mid
        else:
            min_p = mid+1
    print(max_p)

