n, k = [ int( val ) for val in raw_input( ).split( " " ) ]
w = [ int( raw_input( ) ) for val in range( n ) ]
sumW = sum( w )
maxW = max( w )

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 int( raw_input( ) ) for val in range( n ) for val in range( n ) val range( n ) range n for val in range( n ) int( raw_input( ) ) int raw_input( ) raw_input w = [ int( raw_input( ) ) for val in range( n ) ] w [ int( raw_input( ) ) for val in range( n ) ] sumW = sum( w ) sumW sum( w ) sum w maxW = max( w ) maxW max( w ) max w 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 loadings = w[i] w[i] loadings minP = sumW sumW minP minP = maxW maxW minP middle = ( left+right )//2 ( left+right )//2 middle loadings = 0 0 loadings i = loadings = 0 0 i sumW = sum( w ) sum( w ) sumW right = 100000*10000 100000*10000 right truckCnt = i = loadings = 0 0 truckCnt truckCnt += 1 1 truckCnt left = maxW maxW left minP = 0 0 minP loadings += w[i] w[i] loadings n, k = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] n left = middle + 1 middle + 1 left right = middle - 1 middle - 1 right maxW = max( w ) max( w ) maxW minP = middle middle minP k = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] k w = [ int( raw_input( ) ) for val in range( n ) ] [ int( raw_input( ) ) for val in range( n ) ] w i += 1 1 i
n, k = [ int( val ) for val in raw_input( ).split( " " ) ]
w = [ int( raw_input( ) ) for val in range( n ) ]
sumW = sum( w )
maxW = max( w )

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 )