#include <bits/stdc++.h>
using namespace std;
int means(int N, vector<int> &binary) {
  int count = 0;
  int check = 0;
  int right = -1;
  int end = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (binary[i] == 1) {
      count++;
      if (check == 0) {
        right = i;
        check = 1;
      }
    }
  }
  if (right == N - 1 - count) {
    int hmt = 0;
    for (int i = right; i >= 0; i--) {
      if (binary[i] == 1) {
        hmt++;
        if (hmt == N / 2) {
          end = 1;
          break;
        }
      } else {
        for (int j = i - 1; j >= 0; j--) {
          if (binary[j] == 1) {
            binary[j + 1] = 1;
            binary[j] = 0;
            for (int k = j + 2; k < N; k++) {
              binary[k] = 0;
            }
            for (int k = j + 2; k < j + 2 + hmt; k++) {
              binary[k] = 1;
            }
            break;
          } else {
            if (j == 0) {
              for (int k = 0; k < N; k++) {
                binary[k] = 0;
              }
              for (int k = 0; k < count + 1; k++) {
                binary[k] = 1;
              }
            }
          }
        }
        break;
      }
    }
  } else if (right != -1) {
    binary[right] = 0;
    binary[right + 1] = 1;
  } else {
    binary[0] = 1;
  }
  if (end == 0) {
    return 0;
  } else {
    return 1;
  }
}
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> binary(N);
  vector<int> broken(M);
  for (int i = 0; i < M; i++) {
    cin >> broken[i];
  }
  long count = 0;
  int sum, i, j, judge;
  while (1) {
    sum = 0;
    i = 0;
    j = 0;
    while (1) {
      if (sum == N) {
        count++;
        break;
      }
      if (sum == broken[i]) break;
      if (sum > N) break;
      if (binary[j] == 0) {
        sum++;
      } else {
        sum += 2;
      }
      j++;
      if (sum > broken[i]) {
        i++;
      }
    }
    judge = means(N, binary);
    if (judge == 1) break;
  }
  cout << count % 1000000007 << endl;
}
