MOD = 10**9 + 7 K = int(input()) N = int(input()) x = list(map(int, input().split())) # Filter x to include only steps <= K and sort them x = [xi for xi in x if xi <= K] x.sort() dp = [0] * (K + 1) sum_dp = [0] * (K + 1) dp[0] = 1 sum_dp[0] = 1 for k in range(1, K + 1): total = 0 # Find the rightmost index where x_i <= k using binary search left, right = 0, len(x) while left < right: mid = (left + right) // 2 if x[mid] <= k: left = mid + 1 else: right = mid # Iterate through all valid x_i (up to left-1) for xi in x[:left]: prev = k - xi if prev >= 0: total += sum_dp[prev] if prev - 1 >= 0: total -= sum_dp[prev - 1] # Ensure the total stays within the modulo bounds total %= MOD dp[k] = total % MOD sum_dp[k] = (sum_dp[k - 1] + dp[k]) % MOD print(dp[K] % MOD)