#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];
map < int, int > M;
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 <= 100000);
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] = add(M[sum[n] - n], 1);
for(int i = n; i >= 1; i--) {
if(!a[i - 1]) {
dp[i] = M[sum[i - 1] - i + 1];
}
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)] = add(M[sum[i - 1] - (i - 1)], sumDp[i + 1]);
}
printf("%d\n", ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgcGFpciA8IGludCwgaW50ID4gaWk7Cgpjb25zdCBpbnQgTiA9IDFlNiArIDU7CmNvbnN0IGludCBtb2QgPSAxZTkgKyA3OwoKaW50IG4sIG07CmludCBhW05dLCBzdW1bTl0sIGRwW05dLCBzdW1EcFtOXTsKbWFwIDwgaW50LCBpbnQgPiBNOwoKaW5saW5lIGludCBhZGQoaW50IHgsIGludCB5KSB7CglyZXR1cm4geCArIHkgPj0gbW9kID8geCArIHkgLSBtb2QgOiB4ICsgeTsKfQoKaW50IG1haW4oKSB7CgoJc2NhbmYoIiVkICVkIiwgJm4sICZtKTsKCglhc3NlcnQobiA8PSAxMDAwMDApOwoKCWZvcihpbnQgaSA9IDE7IGkgPD0gbTsgaSsrKSB7C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