#include <bits/stdc++.h>
using namespace std;
long long fib(int x);
long long fib(int x) {
  long long dp[100000];
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 2; i < x; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  return dp[x - 1];
}
int main() {
  int N, M;
  cin >> N >> M;
  int a[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i];
  }
  long long ans = 1;
  int j = 0;
  int judge = 0;
  for (int i = 0; i < M; i++) {
    if (a[i] - j == 1 && j != 0) {
      judge = 1;
    } else if (j != 0) {
      ans = fib(a[i] - j - 2) * ans;
      j = a[i];
    } else {
      ans = fib(a[i] - j - 1) * ans;
      j = a[i];
    }
  }
  ans = fib(N - a[M - 1] - 1) * ans;
  long long right_ans = ans % 1000000007;
  cout << ans << endl;
  if (judge == 1) {
    right_ans = 0;
  }
  cout << right_ans << endl;
  return 0;
}
