#include <bits/stdc++.h>
using namespace std;
long long dp[100005];
int main(void) {
  int n, m;
  cin >> n >> m;
  priority_queue<int, vector<int>, greater<int> > a;
  for (int i = 0; i < (m); ++i) {
    int x;
    cin >> x;
    a.push(x);
  }
  int i = 1;
  if (a.top() == 1) {
    dp[1] = 0;
    a.pop();
  } else {
    dp[1] = 1;
  }
  if (a.top() == 2) {
    dp[2] = 0;
  }
  if (dp[1] == 0 && a.top() != 2) {
    dp[2] = 1;
  }
  if (dp[1] == 1 && a.top() != 2) {
    dp[2] = 2;
  }
  if (a.top() == 2) {
    a.pop();
  }
  while (i <= n) {
    if ((i + 2) == a.top()) {
      dp[i + 2] = 0;
      a.pop();
    } else {
      dp[i + 2] = dp[i + 1] + dp[i];
    }
    i++;
  }
  long long ans = 0;
  ans = dp[n] % 1000000007;
  cout << dp[1] << dp[2] << endl;
  cout << ans << endl;
  return 0;
}
