N, K = map(int, input().split())
W = [int(input()) for i in range(N)]


def num_v(p):
    v, kp, vp = 0, 1, 0
    for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

    return v


def main():
    left, right = 0, sum(W)

    while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

    print(left)


if __name__ == '__main__':
    main()
 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 W = [int(input()) for i in range(N)] W [int(input()) for i in range(N)] def num_v(p):
    v, kp, vp = 0, 1, 0
    for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

    return v num_v v, kp, vp = 0, 1, 0 v 0 kp 1 vp 0 for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

     i range(N) range N while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

         vp + W[i] > p vp + W[i] vp W[i] W i p kp += 1 kp 1 vp = 0 vp 0 if kp > K:
                break

         kp > K kp K break vp += W[i] vp W[i] W i v += 1 v 1 continue break return v v p p def main():
    left, right = 0, sum(W)

    while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

    print(left) main left, right = 0, sum(W) left 0 right sum(W) sum W while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

     left < right left right mid = (left+right) // 2 mid (left+right) // 2 left+right left right 2 v = num_v(mid) v num_v(mid) num_v mid if v == N:
            right = mid
        else:
            left = mid + 1

     v == N v N right = mid right mid left = mid + 1 left mid + 1 mid 1 print(left) print left if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    left, right = 0, sum(W)

    while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

    print(left) def main():
    left, right = 0, sum(W)

    while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

    print(left) main W = [int(input()) for i in range(N)] [int(input()) for i in range(N)] W K = map(int, input().split()) map(int, input().split()) K N, K = map(int, input().split()) map(int, input().split()) N def num_v(p):
    v, kp, vp = 0, 1, 0
    for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

    return v def num_v(p):
    v, kp, vp = 0, 1, 0
    for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

    return v num_v
N, K = map(int, input().split())
W = [int(input()) for i in range(N)]


def num_v(p):
    v, kp, vp = 0, 1, 0
    for i in range(N):
        while vp + W[i] > p:
            kp += 1
            vp = 0
            if kp > K:
                break

        else:
            vp += W[i]
            v += 1
            continue

        break

    return v


def main():
    left, right = 0, sum(W)

    while left < right:
        mid = (left+right) // 2
        v = num_v(mid)

        if v == N:
            right = mid
        else:
            left = mid + 1

    print(left)


if __name__ == '__main__':
    main()

