import sys
n, k = map(int, input().split())
T = [int(input()) for i in range(n)]
def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i
def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r
x=Allocation()
print(x)
 import sys sys 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 T = [int(input()) for i in range(n)] T [int(input()) for i in range(n)] def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i c global k,T,n i=0 i 0 for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	 j range(k) range k s=0 s 0 while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	 s+T[i]<=mid s+T[i] s T[i] T i mid s+=T[i] s T[i] T i i+=1 i 1 if(i == n):
				return n
	 i == n i n return n n return i i mid mid def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r Allocation l=0 l 0 r=sys.maxsize r sys.maxsize sys maxsize while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	 r-l>1 r-l r l 1 mid=(l+r)//2 mid (l+r)//2 l+r l r 2 v=c(mid) v c(mid) c mid if (v>=n):
			r=mid
		else:
			l=mid
	 v>=n v n r=mid r mid l=mid l mid return r r x=Allocation() x Allocation() Allocation print(x) print x n, k = map(int, input().split()) map(int, input().split()) n x=Allocation() Allocation() x def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i c k = map(int, input().split()) map(int, input().split()) k def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r Allocation T = [int(input()) for i in range(n)] [int(input()) for i in range(n)] T
import sys
n, k = map(int, input().split())
T = [int(input()) for i in range(n)]
def c(mid):
	global k,T,n
	i=0
	for j in range(k):
		s=0
		while s+T[i]<=mid:
			s+=T[i]
			i+=1
			if(i == n):
				return n
	return i
def Allocation():
	l=0
	r=sys.maxsize
	while r-l>1:
		mid=(l+r)//2
		v=c(mid)
		if (v>=n):
			r=mid
		else:
			l=mid
	return r
x=Allocation()
print(x)

