def bsearch(low: int, high: int, fun, is_complement=False) -> int: def pred(x: int) -> bool: return not fun(x) if is_complement else fun(x) lo = low hi = high res = low while lo <= hi: m = (lo + hi) // 2 if pred(m): res = max(res, m) lo = m + 1 else: hi = m - 1 return res + 1 if is_complement else res # 金塊を m 個生成できるか def can(m: int) -> bool: rest = 0 for a in A: rest += a - (m * M) if rest < 0: return False return rest >= 0 N, M = map(int, input().split()) A = list(map(int, input().split())) res = bsearch(0, max(A), can) print(res)