#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, M;
  cin >> N >> M;
  vector<int> a(M);
  long mod = 1e9 + 7;
  int tmp = -11;
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    a[i] = x;
    if (x == tmp + 1) {
      cout << 0 << endl;
      return 0;
    }
    tmp = x;
  }
  vector<long> dp(100005);
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 2; i < 100005; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] %= mod;
  }
  cout << dp[100] << endl;
  long ans = 1;
  int now = 0;
  int next = 0;
  for (int i = 0; i < M; i++) {
    next = a[i] - 1;
    ans *= dp[next - now];
    now = next + 2;
    ans %= mod;
  }
  next = N;
  ans *= dp[next - now];
  ans %= mod;
  cout << ans << endl;
}
