p_max = 100000 * 10000

nk = list(map(int, input().split()))
w = [int(input()) for i in range(nk[0])]


def search(pt):
    m = 0
    for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
    return m


def main():
    st_p = p = 0
    en_p = p_max
    while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
    return en_p


if __name__ == '__main__':
    print(main())
 p_max = 100000 * 10000 p_max 100000 * 10000 100000 10000 nk = list(map(int, input().split())) nk list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split int(input()) for i in range(nk[0]) for i in range(nk[0]) i range(nk[0]) range nk[0] nk 0 for i in range(nk[0]) int(input()) int input() input w = [int(input()) for i in range(nk[0])] w [int(input()) for i in range(nk[0])] def search(pt):
    m = 0
    for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
    return m search m = 0 m 0 for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
     j range(nk[1]) range nk[1] nk 1 weight = 0 weight 0 while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
     weight + w[m] <= pt weight + w[m] weight w[m] w m pt weight += w[m] weight w[m] w m m += 1 m 1 if m == nk[0]:
                return nk[0]
     m == nk[0] m nk[0] nk 0 return nk[0] nk[0] nk 0 return m m pt pt def main():
    st_p = p = 0
    en_p = p_max
    while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
    return en_p main st_p = p = 0 st_p 0 = p = 0 p 0 en_p = p_max en_p p_max while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
     en_p - st_p > 1 en_p - st_p en_p st_p 1 p = int((en_p + st_p) / 2) p int((en_p + st_p) / 2) int (en_p + st_p) / 2 en_p + st_p en_p st_p 2 chk = search(p) chk search(p) search p if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
     chk >= nk[0] chk nk[0] nk 0 en_p = p en_p p st_p = p st_p p return en_p en_p if __name__ == '__main__':
    print(main()) __name__ == '__main__' __name__ '__main__' print(main()) print main() main def main():
    st_p = p = 0
    en_p = p_max
    while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
    return en_p def main():
    st_p = p = 0
    en_p = p_max
    while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
    return en_p main def search(pt):
    m = 0
    for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
    return m def search(pt):
    m = 0
    for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
    return m search w = [int(input()) for i in range(nk[0])] [int(input()) for i in range(nk[0])] w p_max = 100000 * 10000 100000 * 10000 p_max nk = list(map(int, input().split())) list(map(int, input().split())) nk
p_max = 100000 * 10000

nk = list(map(int, input().split()))
w = [int(input()) for i in range(nk[0])]


def search(pt):
    m = 0
    for j in range(nk[1]):
        weight = 0
        while weight + w[m] <= pt:
            weight += w[m]
            m += 1
            if m == nk[0]:
                return nk[0]
    return m


def main():
    st_p = p = 0
    en_p = p_max
    while en_p - st_p > 1:
        p = int((en_p + st_p) / 2)
        chk = search(p)
        if chk >= nk[0]:
            en_p = p
        else:
            st_p = p
    return en_p


if __name__ == '__main__':
    print(main())

