#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    int fibonacci[N + 1];
    fibonacci[0] = 1;
    fibonacci[1] = 1;
    for (int i = 2; i < N + 1; i++) {
      fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
    }
    printf("%d\n", fibonacci[N]);
    return 0;
  }
  int w[M];
  for (int i = 0; i < M; i++) cin >> w[i];
  int sub[M + 1];
  sub[0] = w[0] - 1;
  sub[M] = N - w[M - 1] - 1;
  int maxsub = max(sub[0], sub[M]);
  if (M >= 2) {
    for (int i = 0; i < M - 1; i++) {
      if (w[i] == w[i + 1]) {
        return 0;
      }
      sub[i + 1] = w[i + 1] - w[i] - 2;
      if (sub[i + 1] > maxsub) maxsub = sub[i + 1];
    }
  }
  int fibonacci[maxsub + 1];
  fibonacci[0] = 1;
  fibonacci[1] = 1;
  for (int i = 2; i < maxsub + 1; i++) {
    fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
  }
  long int sum = 1;
  for (int i = 0; i < M + 1; i++) {
    cout << fibonacci[sub[i]] << ", ";
    sum *= fibonacci[sub[i]];
  }
  cout << endl;
  cout << sum % 1000000007 << endl;
  return 0;
}
