#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
template <typename T>
void printV(const std::vector<T>& v, const char* const separator = " ") {
  if (!v.empty()) {
    std::copy(v.begin(), --v.end(),
              std::ostream_iterator<T>(std::cout, separator));
    std::cout << v.back() << "\n";
  }
}
int64_t gcd(int64_t a, int64_t b) { return b != 0 ? gcd(b, a % b) : a; }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
int Max(int a, int b, int c) {
  int temp = max(a, b);
  return max(temp, c);
}
int Min(int a, int b, int c) {
  int temp = min(a, b);
  return min(temp, c);
}
bool integer(double num) { return floor(num) == num; }
int64_t fact(int num) {
  if (num == 0)
    return 1;
  else
    return num * fact(num - 1);
}
int64_t yakusu(int n) {
  int cnt = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
      if (i * i != n) cnt++;
    }
  }
  return cnt;
}
int cnt = 0;
bool is_prime[50000 + 1];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
void euclid(int64_t N, int64_t a, int64_t b) {
  for (int64_t d = a + b; d <= N; d += b) {
    euclid(N, b, d);
  }
}
int N, m, b, in2, in3;
string in;
int maps[41][41];
int place[41][41];
int maps2[41][41];
int place2[41][41];
vector<int> roboty(100);
vector<int> robotx(100);
vector<int> robotdirec(100);
vector<int> roboty2(100);
vector<int> robotx2(100);
vector<int> robotdirec2(100);
int gy, gx;
int score(void) {
  int cnt = 0;
  int point = 0;
  int dead = 0;
  robotx = robotx2;
  roboty = roboty2;
  robotdirec = robotdirec2;
  for (int i = 0; i < 41; ++i) {
    for (int j = 0; j < 41; ++j) {
      maps[i][j] = maps2[i][j];
    }
  }
  int next_x, next_y;
  while (cnt < 500 || dead > 90) {
    for (int i = 0; i < m; ++i) {
      if (place[roboty[i]][robotx[i]] > 0) {
        robotdirec[i] = place[roboty[i]][robotx[i]];
      }
      if (robotx[i] >= 500) {
        continue;
      }
      if (robotdirec[i] > 15) {
        next_x = robotx[i] + robotdirec[i] - 20;
        if (next_x > N - 1) next_x = 0;
        if (next_x < 0) next_x = N - 1;
        if (next_x == gx && roboty[i] == gy) {
          point += 1000;
          robotx[i] += 600;
          roboty[i] += 600;
        } else if (maps[roboty[i]][next_x] >= 0) {
          robotx[i] = next_x;
          maps[roboty[i]][next_x] = 1;
        } else {
          robotx[i] += 1000;
          roboty[i] += 1000;
        }
      } else {
        next_y = roboty[i] + robotdirec[i] - 10;
        if (next_y > N - 1) next_y = 0;
        if (next_y < 0) next_y = N - 1;
        if (next_y == gy && robotx[i] == gx) {
          point += 1000;
          robotx[i] += 600;
          roboty[i] += 600;
        } else if (maps[next_y][robotx[i]] >= 0) {
          roboty[i] = next_y;
          maps[next_y][robotx[i]] = 1;
        } else {
          robotx[i] += 1000;
          roboty[i] += 1000;
        }
      }
    }
    cnt++;
  }
  for (int j = 0; j < N; ++j) {
    for (int i = 0; i < N; ++i) {
      if (place[i][j] > 0) point -= 10;
      if (maps[i][j] == 1) point++;
    }
  }
  return point;
}
std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}
uint64_t get_rand_range(uint64_t min_val, uint64_t max_val) {
  static std::mt19937_64 mt64(0);
  std::uniform_int_distribution<uint64_t> get_rand_uni_int(min_val, max_val);
  return get_rand_uni_int(mt64);
}
int64_t cnts(int64_t start, int64_t end) {
  int64_t ans = 1;
  int64_t num = -start + end;
  int64_t t2, t1;
  if (num % 2 == 0) ans++;
  for (int i = 0; i <= num / 2; ++i) {
    t1 = num - i * 2;
    if (t1 != 0 && i != 0) ans += comb(t1 + i, t1)[t1 + i][t1];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
  }
  int64_t ans = 1;
  for (int j = 0; j < m; ++j) {
    if (j == 0) {
      ans = ans * cnts(0, a[j] - 1) % 1000000007;
    }
    if (j == m - 1) {
      ans = ans * cnts(a[j] + 1, n) % 1000000007;
    } else {
      ans = ans * cnts(a[j] + 1, a[j + 1] - 1) % 1000000007;
    }
  }
  for (int k = 0; k < m - 1; ++k) {
    if (a[k] == a[k + 1] - 1) ans = 0;
  }
  cout << ans % 1000000007 << "\n";
  return 0;
}
