n, m = map(int, input().split()) B = list(map(int, input().split())) A = [0]*m for i, b in enumerate(B): A[i] = n-b C = [0]+A from itertools import accumulate C = list(accumulate(C)) ans = float('inf') for i in range(m): y = m*(C[m]-C[i]+i) if (m-i)*A[i] <= m*(C[m]-C[i]+i): x = y/(m-i) ans = min(ans, B[0]-1+min(x/m+1, n-B[0])) print(ans)