#include #include #include using namespace std; #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") const int mod = 1000000007; int K, N, M, X[100009], Y[100009]; long long dp[100009]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> K >> N; int mx = 0; for (int i = 0; i < N; ++i) { cin >> X[i]; if (X[i] > K) { N = i; break; } } if (N * 2 <= K) { dp[0] = 1; for (int i = 1; i <= K; ++i) { for (int j = 0; j < N && X[j] <= i; ++j) { dp[i] += dp[i - X[j]]; } dp[i] %= mod; } cout << dp[K] << endl; } else { assert(false); for (int i = 1; i <= K; ++i) { if (!binary_search(X, X + N, i)) { Y[M++] = i; } } long long sum = 1; dp[0] = 1; for (int i = 1; i <= K; ++i) { dp[i] = sum; for (int j = 0; j < M && Y[j] <= i; ++j) { dp[i] -= dp[i - Y[j]]; } dp[i] %= mod; sum += dp[i]; } cout << dp[K] << endl; } return 0; }