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

def check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True

left = 0
right = 2000000000
while((left + 1) < right):
    mid = (left + right) // 2
    track = check(mid)
    if check(mid):
        right = mid
    else:
        left = mid 
        
print(right) 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 check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True check track = 0 track 0 tmp_w = 0 tmp_w 0 for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
     i range(N) range N if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
     w[i] > p w[i] w i p return False False if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
     (tmp_w + w[i]) > p tmp_w + w[i] tmp_w w[i] w i p track += 1 track 1 tmp_w = w[i] tmp_w w[i] w i tmp_w += w[i] tmp_w w[i] w i if track + 1 > K:
        return False
    else:
        return True track + 1 > K track + 1 track 1 K return False False return True True p p left = 0 left 0 right = 2000000000 right 2000000000 while((left + 1) < right):
    mid = (left + right) // 2
    track = check(mid)
    if check(mid):
        right = mid
    else:
        left = mid 
         (left + 1) < right left + 1 left 1 right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 track = check(mid) track check(mid) check mid if check(mid):
        right = mid
    else:
        left = mid 
         check(mid) check mid right = mid right mid left = mid left mid print(right) print right mid = (left + right) // 2 (left + right) // 2 mid right = 2000000000 2000000000 right right = mid mid right K = map(int,input().split()) map(int,input().split()) K N, K = map(int,input().split()) map(int,input().split()) N left = mid mid left w = [int(input()) for i in range(N)] [int(input()) for i in range(N)] w track = check(mid) check(mid) track def check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True def check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True check left = 0 0 left
N, K = map(int,input().split())
w = [int(input()) for i in range(N)]

def check(p):
    track = 0
    tmp_w = 0
    for i in range(N):
        if w[i] > p:
            return False
        else:
            if (tmp_w + w[i]) > p:
                track += 1
                tmp_w = w[i]
            else:
                tmp_w += w[i]
    if track + 1 > K:
        return False
    else:
        return True

left = 0
right = 2000000000
while((left + 1) < right):
    mid = (left + right) // 2
    track = check(mid)
    if check(mid):
        right = mid
    else:
        left = mid 
        
print(right)
