#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000009
vector<long long> fact, inv_fact;
// Fast modular exponentiation
long long power(long long base, long long exp, long long mod) {
long long result = 1;
base %= mod;
while (exp > 0) {
if (exp & 1) result = (result * base) % mod;
base = (base * base) % mod;
exp >>= 1;
}
return result;
}
// Precompute factorials and their modular inverses
void precomputeFactorials(int max_n) {
fact.resize(max_n + 1);
inv_fact.resize(max_n + 1);
// Compute factorials
fact[0] = 1;
for (int i = 1; i <= max_n; i++) {
fact[i] = (fact[i-1] * i) % MOD;
}
// Compute modular inverses using Fermat's little theorem
// inv_fact[i] = (i!)^(-1) mod MOD = (i!)^(MOD-2) mod MOD
inv_fact[max_n] = power(fact[max_n], MOD - 2, MOD);
for (int i = max_n - 1; i >= 0; i--) {
inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
}
}
// Calculate multinomial coefficient: n! / (c1! * c2! * ... * cm!)
long long multinomial(int n, const vector<int>& counts) {
long long result = fact[n];
for (int c : counts) {
result = (result * inv_fact[c]) % MOD;
}
return result;
}
long long solve(int n, int m, vector<int>& arr) {
// Edge cases
if (n == 0) return 1;
if (m <= 1) return 1;
// Remove colors with 0 balls and filter valid counts
vector<int> counts;
for (int x : arr) {
if (x > 0) {
counts.push_back(x);
}
}
// If we have <= 1 colors with balls, only 1 arrangement possible
if (counts.size() <= 1) return 1;
// Precompute factorials up to n
precomputeFactorials(n);
// Sort counts in descending order to find two largest easily
sort(counts.begin(), counts.end(), greater<int>());
vector<int> newCounts;
newCounts.push_back(counts[0] + counts[1]); // Merge two largest
for (int i = 2; i < counts.size(); i++) {
newCounts.push_back(counts[i]);
}
return multinomial(n, newCounts);
}
int main() {
int n, m;
cin >> n >> m;
vector<int> arr(m);
for (int i = 0; i < m; i++) {
cin >> arr[i];
}
cout << solve(n, m, arr) << "\n";
return 0;
}