const allocate = (n, k, wList) => {
  // console.log(n);
  // console.log(k);
  // console.log(wList);

  const check = (P) => {
    let i = 0;
    for (let j=0; j<k; j++) {
      let s = 0;
      while(s + wList[i] <= P) {
        s += wList[i];
        i++;
        if (i === n) return n;
      }
    }
    return i;
  };

  let left = 0;
  let right = 100000 * 10000;
  let mid;
  while (left < right) {
    const sum = left + right;
    mid = (sum % 2 === 1) ? (sum - 1) / 2 : sum / 2;
    const v = check(mid);
    // console.log(`left: ${left}, right: ${right}, sum: ${sum}, mid: ${mid}`);
    // console.log(`v: ${v}`);
    if (v >= n) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return right;
};

let inputStr = '';

process.stdin.on('data', (input) => { inputStr += input; });

process.stdin.on('end', () => {
  const arr = inputStr.split('\n');
  const [n, k] = arr.shift().split(' ');
  const wList = arr.map(v => Number(v));
  console.log(allocate(Number(n), Number(k), wList));
})
