L = int(input()) N = int(input()) W = list(map(int, input().split())) INF = 1<<60 dp = [-INF]*(L+1) dp[0] = 0 for w in W: for i in range(L+1)[::-1]: if i+w<=L and dp[i+w]