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 set = new HashSet<>(); for (int i = 0; i < n; i++) { if (set.contains(i - 1)) { continue; } long sum = 0; int cnt = 0; boolean flg = false; 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); } else { flg = true; } } } if (cnt >= k) { return true; } } return false; } }