from heapq import heappush, heappop n, m = map(int, input().split()) q = list(range(m)) for t in map(int, input().split()): v = heappop(q) i = v & ((1 << 32) - 1) sm = v >> 32 sm += t heappush(q, sm << 32 | i) print(max(q) >> 32)