inf = 10**9 C = int(input()) N = int(input()) A = list(map(int, input().split())) dp = [inf] * (C + 1) dp[0] = 0 for a in A: for i in range(C - a + 1): dp[i + a] = min(dp[i + a], dp[i] + 1) if dp[C] >= inf: print(-1) else: print(dp[C])