#include <bits/stdc++.h>
using namespace std;
const unsigned long MOD = 1000000007;
int main() {
  int N, M, *a, i, x, memo;
  unsigned long sum = 0, *d;
  cin >> N >> M;
  a = new int[M];
  d = new unsigned long[N];
  d[0] = 1;
  if (N > 2) {
    d[1] = 1;
    d[2] = 2;
  } else {
    if (N == 2) {
      d[1] = 1;
    }
  }
  for (i = 0; i < M; i++) {
    cin >> a[i];
    if (i != 0) {
      if (a[i] - a[i - 1] == 1) {
        cout << 0 << endl;
        return 0;
      } else {
        x = a[i] - a[i - 1] - 2;
        if (x > memo) {
          if (memo < 2) {
            memo = 2;
          }
          for (int j = memo + 1; j <= x; j++) {
            d[j] = d[j - 1] + d[j - 2];
            d[j] = d[j] % MOD;
          }
          memo = x;
        }
        sum *= d[x];
        sum = sum % MOD;
      }
    } else {
      memo = a[0] - 1;
      if (memo > 2) {
        for (int j = 3; j <= memo; j++) {
          d[j] = d[j - 1] + d[j - 2];
          d[j] %= MOD;
        }
      }
      sum += d[memo];
      sum %= MOD;
    }
  }
  x = N - a[M - 1] - 1;
  if (x > memo) {
    for (int j = memo + 1; j <= x; j++) {
      d[j] = d[j - 1] + d[j - 2];
      d[j] %= MOD;
    }
    memo = x;
  }
  sum *= d[x];
  sum %= MOD;
  cout << d[20] << endl;
  cout << sum << endl;
  return 0;
}
