#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% T, N, *A = map(int, read().split()) # %% INF = 10 ** 9 dp = [INF] * (1 << N) dp[0] = 0 for subset in range(1 << N): for i, x in enumerate(A): if subset & (1 << i): t = dp[subset ^ (1 << i)] q, r = divmod(t, T) if r + x <= T: t += x else: t = (q + 1) * T + x if dp[subset] > t: dp[subset] = t # %% answer = (dp[-1] + T - 1) // T print(answer)