import numpy as np C = int(input()) N = int(input()) A = np.array(list(map(int, input().split()))) MAX = C * 2 dp = np.full(C + 1, MAX) dp[0] = 0 for i in range(C): dp[A[np.where(A <= C - i)] + i] = np.minimum(dp[A[np.where(A <= C - i)] + i], dp[i] + 1) print(ans if (ans :=dp[C]) != MAX else -1)