using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace AtCoder_Grand_Contest_034 {
	class Program {
		static void Main(string[] args) {
			var input = Helper<int>.ReadLine();
			var n = input[0];
			var m = input[1];

			var aList = Helper<int>.Read(m);
			var aIndex = 0;

			var currentPosition = 0;
			var stepLog = new List<int> { 0 };
			var stepCount = 1;

			while (currentPosition != n) {
				if (aList[aIndex] != currentPosition + 1) {
					stepLog.Add(currentPosition + 1);
					stepCount++;
					currentPosition += 1;
				} else if (aList[aIndex] != currentPosition + 2) {
					stepLog.Add(currentPosition + 2);
					stepCount++;

					if (aIndex + 1 < m) {
						aIndex++;
					}

					currentPosition += 2;
				} else {
					Console.WriteLine(0);
					return;
				}
			}

			var skipableCount = 0;
			for (int index = 0; index < stepCount - 2; index++) {
				if (stepLog[index] + 2 == stepLog[index + 2]) {
					skipableCount++;
				}
			}

			Console.WriteLine(Math.Pow(2, skipableCount) % 1000000007);
		}
	}

	public static class Helper<T> {
		public static T[] Read(int count) {
			var result = new T[count];
			for (int index = 0; index < count; index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(Console.ReadLine());
			}
			return result;
		}

		public static T[] ReadLine() {
			var input = Console.ReadLine();
			var inputs = input.Split(' ');
			var result = new T[inputs.Count()];
			for (int index = 0; index < inputs.Count(); index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(inputs[index]);
			}
			return result;
		}
	}
}
