import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) C,N = I(),I() A = LI() inf = 10**18 dp = [0]*(C+1) # dp[i] = (sum(AjXj) == i 下での sum(Xj) の最小値) for i in range(1,C+1): r = inf for j in range(N): a = A[j] if i >= a: r = min(r,1+dp[i-a]) dp[i] = r ans = dp[-1] print(ans if ans != inf else -1)