MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '4 2
  1
  2
  2
  6'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end



def check(n,k,arr,p)
  i = 0
  k.times do
    s=0
    while(s+arr[i]<=p)
      s+=arr[i]
      i += 1
      return n if(i==n)
    end
  end
  return i;
end

def solve(n,k,arr)
  left=0
  right=100000*10000
  while(right-left>1)
    mid = (left+right)/2
    v = check(n,k,arr,mid)
    if(v >= n)
      right=mid
    else
      left=mid
    end
  end
  return right
end

n,k = line[0].split(" ").map(&:to_i)

arr=[]
(1..n).each do |n|
  arr << line[n].to_i
end

ans = solve(n,k,arr)
puts ans