N,M = map(int,input().split()) A = list(map(int,input().split())) high = 10**9+1 low = 0 while high-low>1: mid = (high+low)//2 d = 0 flag = True for i in range(N): if A[i]>mid*M: d += A[i]-mid*M elif A[i]=mid*M-A[i]: d -= mid*M-A[i] else: flag = False break if flag: low = mid else: high = mid print(low)