#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < int, int > ii;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
int n, m;
int a[N], sum[N], dp[N], sumDp[N];
int M[N + N];
inline int add(int x, int y) {
return x + y >= mod ? x + y - mod : x + y;
}
int main() {
scanf("%d %d", &n, &m);
assert(n <= 1000000);
for(int i = 1; i <= m; i++) {
int x;
scanf("%d", &x);
a[x]++;
}
for(int i = 1; i <= n; i++)
sum[i] = sum[i - 1] + a[i];
dp[n + 1] = 1;
int ans = 0;
sumDp[n + 1] = dp[n + 1];
M[sum[n] - n + N] = add(M[sum[n] - n + N], 1);
for(int i = n; i >= 1; i--) {
if(!a[i - 1]) {
dp[i] = M[sum[i - 1] - i + 1 + N];
}
if(a[i])
ans = 0;
ans = add(ans, dp[i]);
if(a[i])
sumDp[i] = dp[i];
else
sumDp[i] = add(sumDp[i + 1], dp[i]);
if(!a[i])
M[sum[i - 1] - (i - 1) + N] = add(M[sum[i - 1] - (i - 1) + N], sumDp[i + 1]);
}
printf("%d\n", ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgcGFpciA8IGludCwgaW50ID4gaWk7Cgpjb25zdCBpbnQgTiA9IDFlNiArIDU7CmNvbnN0IGludCBtb2QgPSAxZTkgKyA3OwoKaW50IG4sIG07CmludCBhW05dLCBzdW1bTl0sIGRwW05dLCBzdW1EcFtOXTsKaW50IE1bTiArIE5dOwoKaW5saW5lIGludCBhZGQoaW50IHgsIGludCB5KSB7CglyZXR1cm4geCArIHkgPj0gbW9kID8geCArIHkgLSBtb2QgOiB4ICsgeTsKfQoKaW50IG1haW4oKSB7CgoJc2NhbmYoIiVkICVkIiwgJm4sICZtKTsKCglhc3NlcnQobiA8PSAxMDAwMDAwKTsKCglmb3IoaW50IGkgPSAxOyBpIDw9IG07IGkrKykgew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