C = int(raw_input()) N = int(raw_input()) a = map(int,raw_input().split(" ")) dp = {C:0} for i in range(N): tmp_dp = dict() for c,s in dp.iteritems(): for j in range(c/a[i],-1,-1): tmp_c = c - a[i]*j tmp_s = s + j if not (tmp_c in tmp_dp and tmp_dp[tmp_c] <= tmp_s): tmp_dp[tmp_c] = tmp_s dp = tmp_dp if 0 in dp: print dp[0] else: print -1