import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	static int n, k;
	static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		long sum = 0;
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
			sum += a[i];
		}
		br.close();

		long ok = 0;
		long ng = sum / k + 1;
		while (Math.abs(ok - ng) > 1) {
			long mid = (ok + ng) / 2;
			if (can(mid)) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		System.out.println(ok);
	}

	static boolean can(long mid) {
		Set<Integer> set = new HashSet<>();
		boolean flg = false;
		label:
		for (int i = 0; i < n; i++) {
			long sum = 0;
			int cnt = 0;
			for (int j = i; j < i + n; j++) {
				int idx = j % n;
				sum += a[idx];
				if (sum >= mid) {
					cnt++;
					sum = 0;
					if (!flg && !set.add(idx)) {
						flg = true;
						i = idx;
						continue label;
					}
				}
			}
			if (cnt >= k) {
				return true;
			}
			if (flg) {
				break;
			}
		}
		return false;
	}
}