#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int b[m + 1];
  bool c = false;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  b[m] = -1;
  for (int i = 0; i < m - 1; i++) {
    if (b[i] + 1 == b[i + 1]) {
      c = true;
      break;
    }
  }
  int j = 0;
  int a[100000] = {1, 2};
  if (b[0] == 1) {
    a[0] = 0;
    a[1] = 1;
    j = 1;
  }
  cout << a[0] << a[1] << endl;
  if (b[0] == 2) {
    a[1] = 0;
    j = 1;
  }
  if (c) {
    cout << 0 << endl;
  } else {
    for (int i = 2; i < n + 10; i++) {
      if (i + 1 == b[j]) {
        a[i] = 0;
        j++;
      } else {
        a[i] = a[i - 1] + a[i - 2];
      }
    }
    cout << a[n - 1] << endl;
    cout << a[n - 1] % 1000000007 << endl;
  }
}
