n, k =map(int,input().split())
a =list(map(int,input().split()))s =[0]*(n +1)for i inrange(n):s[i +1]= s[i]+ a[i]**2defcheck(x):res =0i =0while i < n:start = iif s[start +1]- s[start]> x:returnFalsei +=1while i < n and s[i +1]- s[start]<= x:i +=1res +=1return res <= kl, r =0, s[n]- s[0]while l < r:mid =(l + r)>>1if check(mid):r = midelse:l = mid +1print(l)