#include using namespace std; using ll = long long; using ull = unsigned long long; using i128 = __int128_t; using pii = pair; using pll = pair; template using vec = vector; template using vvec = vector>; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) constexpr char ln = '\n'; istream& operator>>(istream& is, __int128_t& x) { x = 0; string s; is >> s; int n = int(s.size()), it = 0; if (s[0] == '-') it++; for (; it < n; it++) x = (x * 10 + s[it] - '0'); if (s[0] == '-') x = -x; return is; } ostream& operator<<(ostream& os, __int128_t x) { if (x == 0) return os << 0; if (x < 0) os << '-', x = -x; deque deq; while (x) deq.emplace_front(x % 10), x /= 10; for (int e : deq) os << e; return os; } template ostream& operator<<(ostream& os, const pair& p) { return os << "(" << p.first << ", " << p.second << ")"; } template ostream& operator<<(ostream& os, const vector& v) { os << "{"; for (int i = 0; i < int(v.size()); i++) { if (i) os << ", "; os << v[i]; } return os << "}"; } template inline int SZ(const Container& v) { return int(v.size()); } template inline void UNIQUE(vector& v) { v.erase(unique(v.begin(), v.end()), v.end()); } template inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return true; } return false; } inline int topbit(ull x) { return x == 0 ? -1 : 63 - __builtin_clzll(x); } inline int botbit(ull x) { return x == 0 ? 64 : __builtin_ctzll(x); } inline int popcount(ull x) { return __builtin_popcountll(x); } inline int kthbit(ull x, int k) { return (x >> k) & 1; } inline constexpr long long TEN(int x) { return x == 0 ? 1 : TEN(x-1) * 10; } template inline T ABS(T x) { return max(x, -x); } const string YESNO[2] = {"NO", "YES"}; const string YesNo[2] = {"No", "Yes"}; const string yesno[2] = {"no", "yes"}; inline void YES(bool t = 1) { cout << YESNO[t] << "\n"; } inline void Yes(bool t = 1) { cout << YesNo[t] << "\n"; } inline void yes(bool t = 1) { cout << yesno[t] << "\n"; } inline void print() { cout << "\n"; } template inline void print(const vector& v) { for (auto it = begin(v); it != end(v); ++it) { if (it != begin(v)) cout << " "; cout << *it; } print(); } template inline void print(const T& x, const Args& ... args) { cout << x << " "; print(args...); } #ifdef MINATO_LOCAL inline void debug_out() { cerr << endl; } template inline void debug_out(const T& x, const Args& ... args) { cerr << " " << x; debug_out(args...); } #define debug(...) cerr << __LINE__ << " : [" << #__VA_ARGS__ << "] =", debug_out(__VA_ARGS__) #else #define debug(...) (void(0)) #endif struct fast_ios { fast_ios() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); cerr << fixed << setprecision(7); }; } fast_ios_; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include using namespace atcoder; //using mint = modint998244353; using mint = modint1000000007; //using mint = modint; istream& operator>>(istream& is, modint998244353& M) { long long x; is >> x; M = x; return is; } ostream& operator<<(ostream& os, const modint998244353& M) { return os << M.val(); } istream& operator>>(istream& is, modint1000000007& M) { long long x; is >> x; M = x; return is; } ostream& operator<<(ostream& os, const modint1000000007& M) { return os << M.val(); } template istream& operator>>(istream& is, static_modint& M) { long long x; is >> x; M = x; return is; } template ostream& operator<<(ostream& os, const static_modint& M) { return os << M.val(); } istream& operator>>(istream& is, modint& M) { long long x; is >> x; M = x; return is; } ostream& operator<<(ostream& os, const modint& M) { return os << M.val(); } vector multiply(vector a, vector b) { return convolution(a,b); } vector multiply_naive(vector a, vector b) { int n = int(a.size()), m = int(b.size()); if (!n or !m) return {}; vector ret(n + m - 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ret[i + j] += a[i] * b[j]; } } return ret; } //59501818244292734739283969=5.95*10^25 までの値を正しく計算 //最終的な列の大きさが 2^24 までなら動く //最終的な列の大きさが 2^20 以下のときは,下の 3 つの素数を使ったほうが速い namespace arbitrary_convolution { constexpr int m0 = 167772161; constexpr int m1 = 469762049; constexpr int m2 = 754974721; constexpr int r01 = 104391568; // mint1(m0).inv() constexpr int r02 = 323560596; // mint2(m0).inv() constexpr int r12 = 399692502; // mint2(m1).inv() // constexpr int m0 = 1045430273; // constexpr int m1 = 1051721729; // constexpr int m2 = 1053818881; // constexpr int r01 = 175287122; // mint1(m0).inv() // constexpr int r02 = 395182206; // mint2(m0).inv() // constexpr int r12 = 526909943; // mint2(m1).inv() constexpr int r02r12 = (long long)(r02) * r12 % m2; constexpr long long w1 = m0; constexpr long long w2 = (long long)(m0) * m1; template vector multiply(const vector& a, const vector& b, int mod) { int n = int(a.size()), m = int(b.size()); vector v0 = convolution(a, b); vector v1 = convolution(a, b); vector v2 = convolution(a, b); vector ret(n + m - 1); const int W1 = w1 % mod; const int W2 = w2 % mod; for (int i = 0; i < n + m - 1; i++) { int n1 = v1[i], n2 = v2[i], x = v0[i]; int y = (long long)(n1 + m1 - x) * r01 % m1; int z = ((long long)(n2 + m2 - x) * r02r12 + (long long)(m2 - y) * r12) % m2; ret[i] = ((long long)(x) + (long long)(y) * W1 + (long long)(z) * W2) % mod; } return ret; } template vector multiply(vector a, vector b) { int n = int(a.size()), m = int(b.size()); if (!n or !m) return {}; if (min(n,m) < 128) { if (n < m) { swap(n, m); swap(a, b); } vector ret(n + m - 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ret[i + j] += a[i] * b[j]; } } return ret; } vector a_(n), b_(m); for (int i = 0; i < n; i++) a_[i] = a[i].val(); for (int i = 0; i < m; i++) b_[i] = b[i].val(); vector c = multiply(a_, b_, D::mod()); vector ret(n + m - 1); for (int i = 0; i < n + m - 1; i++) ret[i] = D::raw(c[i]); return ret; } } template (*op)(vector, vector)> struct FormalPowerSeries { using Poly = FormalPowerSeries; vector v; FormalPowerSeries(const vector& v_ = {}) : v(v_) { shrink(); } void shrink() { while (v.size() && v.back() == 0) v.pop_back(); } int size() const { return int(v.size()); } D freq(int p) const { return (p < size()) ? v[p] : D(0); } Poly operator+(const Poly& r) const { int n = max(size(), r.size()); vector res(n); for (int i = 0; i < n; i++) res[i] = freq(i) + r.freq(i); return res; } Poly operator-(const Poly& r) const { int n = max(size(), r.size()); vector res(n); for (int i = 0; i < n; i++) res[i] = freq(i) - r.freq(i); return res; } Poly operator*(const Poly& r) const { return op(v, r.v); } Poly operator*(const D& r) const { int n = size(); vector res(n); for (int i = 0; i < n; i++) res[i] = v[i] * r; return res; } Poly operator*(const vector>& r) const { assert(!r.empty()); int n = size(); int m = r.back().first; vector res(n + m); for (int i = 0; i < n; i++) { for (auto e : r) { res[i + e.first] += v[i] * e.second; } } return res; } Poly operator/(const D& r) const { return *this * r.inv(); } Poly operator/(const Poly& r) const { if (size() < r.size()) return {{}}; int n = size() - r.size() + 1; return (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n); } Poly operator/(const vector>& r) const { assert(!r.empty()); int n = size(); auto [d, c] = r.front(); assert(d == 0 && c != D(0)); D ic = D(1) / c; vector res(n); for (int i = 0; i < n; i++) { for (auto& e : r) { if (e.first and e.first <= i) { res[i] -= res[i - e.first] * e.second; } } res[i] += v[i]; res[i] *= ic; } return res; } Poly operator%(const Poly& r) const { return *this - *this / r * r; } Poly operator<<(int s) const { vector res(size() + s); for (int i = 0; i < size(); i++) res[i + s] = v[i]; return res; } Poly operator>>(int s) const { if (size() <= s) return Poly(); vector res(size() - s); for (int i = 0; i < size() - s; i++) res[i] = v[i + s]; return res; } Poly& operator+=(const Poly& r) { return *this = *this + r; } Poly& operator-=(const Poly& r) { return *this = *this - r; } Poly& operator*=(const Poly& r) { return *this = *this * r; } Poly& operator*=(const D& r) { return *this = *this * r; } Poly& operator*=(const vector>& r) { return *this = *this * r; } Poly& operator/=(const Poly& r) { return *this = *this / r; } Poly& operator/=(const D &r) {return *this = *this/r;} Poly& operator/=(const vector>& r) { return *this = *this / r; } Poly& operator%=(const Poly& r) { return *this = *this % r; } Poly& operator<<=(const size_t& n) { return *this = *this << n; } Poly& operator>>=(const size_t& n) { return *this = *this >> n; } Poly mul(int d, const D& c) const { vector res(size() + d); for (int i = 0; i < size(); i++) { res[i] += v[i]; res[i+d] += v[i] * c; } return res; } Poly div(int d, const D& c) const { vector res(size()); for (int i = 0; i < size(); i++) { res[i] = v[i]; if (i >= d) res[i] -= res[i - d] * c; } return res; } Poly pre(int le) const { return {{v.begin(), v.begin() + min(size(), le)}}; } Poly rev(int n = -1) const { vector res = v; if (n != -1) res.resize(n); reverse(res.begin(), res.end()); return res; } Poly diff() const { vector res(max(0, size() - 1)); for (int i = 1; i < size(); i++) res[i - 1] = freq(i) * i; return res; } Poly inte() const { vector res(size() + 1); for (int i = 0; i < size(); i++) res[i + 1] = freq(i) / (i + 1); return res; } // f * f.inv() = 1 + g(x)x^m Poly inv(int m) const { Poly res = Poly({D(1) / freq(0)}); for (int i = 1; i < m; i *= 2) { res = (res * D(2) - res * res * pre(2 * i)).pre(2 * i); } return res.pre(m); } Poly exp(int n) const { assert(freq(0) == 0); Poly f({1}), g({1}); for (int i = 1; i < n; i *= 2) { g = (g * 2 - f * g * g).pre(i); Poly q = diff().pre(i - 1); Poly w = (q + g * (f.diff() - f * q)).pre(2 * i - 1); f = (f + f * (*this - w.inte()).pre(2 * i)).pre(2 * i); } return f.pre(n); } Poly log(int n) const { assert(freq(0) == 1); auto f = pre(n); return (f.diff() * f.inv(n - 1)).pre(n - 1).inte(); } Poly sqrt(int n) const { assert(freq(0) == 1); Poly f = pre(n + 1); Poly g({1}); for (int i = 1; i < n; i *= 2) { g = (g + f.pre(2 * i) * g.inv(2 * i)) / 2; } return g.pre(n + 1); } Poly pow_mod(ll n, const Poly& mod) { Poly x = *this, r = {{1}}; while (n) { if (n & 1) r = r * x % mod; x = x * x % mod; n >>= 1; } return r; } friend ostream& operator<<(ostream& os, const Poly& p) { if (p.size() == 0) return os << "0"; for (auto i = 0; i < p.size(); i++) { if (p.v[i] != 0) { os << p.v[i] << " x^" << i; if (i != p.size() - 1) os << " + "; } } return os; } }; using Poly = FormalPowerSeries; int main() { int K,N; cin >> K >> N; Poly f; f.v.assign(K+1,0); f.v[0] = 1; rep(i,N) { int x; cin >> x; if (x <= K) f.v[x]--; } f = f.inv(K+1); cout << f.freq(K) << ln; }