n,k = gets.split.map(&:to_i)
w = []
n.times{
  ii = gets.to_i
  w.push(ii)
}

def num(w,k,p)
  i = 0
  for j in 0..k-1
    s = 0
    while s + w[i] <= p
      s += w[i]
      i += 1
      return i if i == w.length
    end
  end
  return i
end

def binary(w,k)
  left = 0
  right = 100000 * 10000
  while right - left > 1
    mid = (left + right) / 2
    v = num(w,k,mid)
    if v >= w.length
      right = mid
    else
      left = mid + 1
    end
  end
  return right
end

puts binary(w,k)