n, k = [ int( val ) for val in raw_input( ).split( " " ) ]
w = []
maxW = sumW = 0
for i in range( n ):
	num = int( raw_input( ) )
	sumW += num
	w.append( num )
	if maxW < num:
		maxW = num

minP = 0
if 1 == k:
	minP = sumW
elif n == k:
	minP = maxW
else:
	left = maxW
	right = 100000*10000
	while left <= right:
		middle = ( left+right )//2
		truckCnt = i = loadings = 0
		while i < n:
			loadings += w[i]
			if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			i += 1

		if truckCnt+1 <= k:
			minP = middle
		
		if k < truckCnt+1:
			left = middle + 1
		else:
			right = middle - 1

print( minP ) int( val ) for val in raw_input( ).split( " " ) for val in raw_input( ).split( " " ) val raw_input( ).split( " " ) ( ).split ( ) raw_input split " " for val in raw_input( ).split( " " ) int( val ) int val n, k = [ int( val ) for val in raw_input( ).split( " " ) ] n [ int( val ) for val in raw_input( ).split( " " ) ] k w = [] w [] maxW = sumW = 0 maxW 0 = sumW = 0 sumW 0 for i in range( n ):
	num = int( raw_input( ) )
	sumW += num
	w.append( num )
	if maxW < num:
		maxW = num i range( n ) range n num = int( raw_input( ) ) num int( raw_input( ) ) int raw_input( ) raw_input sumW += num sumW num w.append( num ) w.append w append num if maxW < num:
		maxW = num maxW < num maxW num maxW = num maxW num minP = 0 minP 0 if 1 == k:
	minP = sumW
elif n == k:
	minP = maxW
else:
	left = maxW
	right = 100000*10000
	while left <= right:
		middle = ( left+right )//2
		truckCnt = i = loadings = 0
		while i < n:
			loadings += w[i]
			if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			i += 1

		if truckCnt+1 <= k:
			minP = middle
		
		if k < truckCnt+1:
			left = middle + 1
		else:
			right = middle - 1 1 == k 1 k minP = sumW minP sumW elif n == k:
	minP = maxW n == k n k minP = maxW minP maxW left = maxW left maxW right = 100000*10000 right 100000*10000 100000 10000 while left <= right:
		middle = ( left+right )//2
		truckCnt = i = loadings = 0
		while i < n:
			loadings += w[i]
			if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			i += 1

		if truckCnt+1 <= k:
			minP = middle
		
		if k < truckCnt+1:
			left = middle + 1
		else:
			right = middle - 1 left <= right left right middle = ( left+right )//2 middle ( left+right )//2 left+right left right 2 truckCnt = i = loadings = 0 truckCnt 0 = i = loadings = 0 i 0 loadings while i < n:
			loadings += w[i]
			if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			i += 1

		 i < n i n loadings += w[i] loadings w[i] w i if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			 middle < loadings middle loadings truckCnt += 1 truckCnt 1 if k < truckCnt+1:
					break
				 k < truckCnt+1 k truckCnt+1 truckCnt 1 break loadings = w[i] loadings w[i] w i i += 1 i 1 if truckCnt+1 <= k:
			minP = middle
		
		 truckCnt+1 <= k truckCnt+1 truckCnt 1 k minP = middle minP middle if k < truckCnt+1:
			left = middle + 1
		else:
			right = middle - 1 k < truckCnt+1 k truckCnt+1 truckCnt 1 left = middle + 1 left middle + 1 middle 1 right = middle - 1 right middle - 1 middle 1 print( minP ) print minP i = loadings = 0 0 i loadings = 0 0 loadings truckCnt = i = loadings = 0 0 truckCnt minP = 0 0 minP loadings += w[i] w[i] loadings loadings = w[i] w[i] loadings w = [] [] w sumW += num num sumW middle = ( left+right )//2 ( left+right )//2 middle i += 1 1 i left = middle + 1 middle + 1 left sumW = 0 0 sumW truckCnt += 1 1 truckCnt minP = sumW sumW minP left = maxW maxW left right = 100000*10000 100000*10000 right minP = maxW maxW minP maxW = sumW = 0 0 maxW maxW = num num maxW k = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] k minP = middle middle minP num = int( raw_input( ) ) int( raw_input( ) ) num n, k = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] n right = middle - 1 middle - 1 right
n, k = [ int( val ) for val in raw_input( ).split( " " ) ]
w = []
maxW = sumW = 0
for i in range( n ):
	num = int( raw_input( ) )
	sumW += num
	w.append( num )
	if maxW < num:
		maxW = num

minP = 0
if 1 == k:
	minP = sumW
elif n == k:
	minP = maxW
else:
	left = maxW
	right = 100000*10000
	while left <= right:
		middle = ( left+right )//2
		truckCnt = i = loadings = 0
		while i < n:
			loadings += w[i]
			if middle < loadings:
				truckCnt += 1
				if k < truckCnt+1:
					break
				loadings = w[i]
			i += 1

		if truckCnt+1 <= k:
			minP = middle
		
		if k < truckCnt+1:
			left = middle + 1
		else:
			right = middle - 1

print( minP )