#include <bits/stdc++.h>
using namespace std;

int n, m;
int a[100000] = {0};
int adiff[100000];
bool flag = false;
long ans = 1;

void solve()
{
  for (int i=0; i<=m; i++) {
    if (adiff[i]-1 >= 0) {
    ans = ans*pow(2,adiff[i]-1) % 1000000007;
    }
  }
}

int main()
{
  cin >> n >> m;

  for (int i = 0; i < m; i++)
  {
    cin >> a[i];
    if (i > 0 && a[i] - a[i - 1] == 1)  {
     cout << 0 << endl;
      return 0;
    }

      if (i == 0)   {
        adiff[i] = a[i] - 1 ;
      } else {
        adiff[i] = a[i] - a[i-1] - 1;
      }
    }
    adiff[m] = n - a[m-1] - 1;

  solve();

  cout << ans  << endl;
}