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)) { break; } long sum = 0; for (int j = i; j < i + n; j++) { int idx = j % n; sum += a[idx]; if (sum >= mid) { set.add(idx); break; } } } for (int i : set) { 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 (cnt >= k) { return true; } } return false; } }