/**
 *    author:  tourist
 *    created: 07.01.2020 00:08:36       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a; swap(a, m);
    u -= t * v; swap(u, v);
  }
  assert(m == 1);
  return u;
}

template <typename T>
class Modular {
 public:
  using Type = typename decay<decltype(T::value)>::type;

  constexpr Modular() : value() {}
  template <typename U>
  Modular(const U& x) {
    value = normalize(x);
  }

  template <typename U>
  static Type normalize(const U& x) {
    Type v;
    if (-mod() <= x && x < mod()) v = static_cast<Type>(x);
    else v = static_cast<Type>(x % mod());
    if (v < 0) v += mod();
    return v;
  }

  const Type& operator()() const { return value; }
  template <typename U>
  explicit operator U() const { return static_cast<U>(value); }
  constexpr static Type mod() { return T::value; }

  Modular& operator+=(const Modular& other) { if ((value += other.value) >= mod()) value -= mod(); return *this; }
  Modular& operator-=(const Modular& other) { if ((value -= other.value) < 0) value += mod(); return *this; }
  template <typename U> Modular& operator+=(const U& other) { return *this += Modular(other); }
  template <typename U> Modular& operator-=(const U& other) { return *this -= Modular(other); }
  Modular& operator++() { return *this += 1; }
  Modular& operator--() { return *this -= 1; }
  Modular operator++(int) { Modular result(*this); *this += 1; return result; }
  Modular operator--(int) { Modular result(*this); *this -= 1; return result; }
  Modular operator-() const { return Modular(-value); }

  template <typename U = T>
  typename enable_if<is_same<typename Modular<U>::Type, int>::value, Modular>::type& operator*=(const Modular& rhs) {
#ifdef _WIN32
    uint64_t x = static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value);
    uint32_t xh = static_cast<uint32_t>(x >> 32), xl = static_cast<uint32_t>(x), d, m;
    asm(
      "divl %4; \n\t"
      : "=a" (d), "=d" (m)
      : "d" (xh), "a" (xl), "r" (mod())
    );
    value = m;
#else
    value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
#endif
    return *this;
  }
  template <typename U = T>
  typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value, Modular>::type& operator*=(const Modular& rhs) {
    int64_t q = static_cast<int64_t>(static_cast<long double>(value) * rhs.value / mod());
    value = normalize(value * rhs.value - q * mod());
    return *this;
  }
  template <typename U = T>
  typename enable_if<!is_integral<typename Modular<U>::Type>::value, Modular>::type& operator*=(const Modular& rhs) {
    value = normalize(value * rhs.value);
    return *this;
  }

  Modular& operator/=(const Modular& other) { return *this *= Modular(inverse(other.value, mod())); }

  template <typename U>
  friend const Modular<U>& abs(const Modular<U>& v) { return v; }

  template <typename U>
  friend bool operator==(const Modular<U>& lhs, const Modular<U>& rhs);

  template <typename U>
  friend bool operator<(const Modular<U>& lhs, const Modular<U>& rhs);

  template <typename U>
  friend std::istream& operator>>(std::istream& stream, Modular<U>& number);

 private:
  Type value;
};

template <typename T> bool operator==(const Modular<T>& lhs, const Modular<T>& rhs) { return lhs.value == rhs.value; }
template <typename T, typename U> bool operator==(const Modular<T>& lhs, U rhs) { return lhs == Modular<T>(rhs); }
template <typename T, typename U> bool operator==(U lhs, const Modular<T>& rhs) { return Modular<T>(lhs) == rhs; }

template <typename T> bool operator!=(const Modular<T>& lhs, const Modular<T>& rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(const Modular<T>& lhs, U rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(U lhs, const Modular<T>& rhs) { return !(lhs == rhs); }

template <typename T> bool operator<(const Modular<T>& lhs, const Modular<T>& rhs) { return lhs.value < rhs.value; }

template <typename T> Modular<T> operator+(const Modular<T>& lhs, const Modular<T>& rhs) { return Modular<T>(lhs) += rhs; }
template <typename T, typename U> Modular<T> operator+(const Modular<T>& lhs, U rhs) { return Modular<T>(lhs) += rhs; }
template <typename T, typename U> Modular<T> operator+(U lhs, const Modular<T>& rhs) { return Modular<T>(lhs) += rhs; }

template <typename T> Modular<T> operator-(const Modular<T>& lhs, const Modular<T>& rhs) { return Modular<T>(lhs) -= rhs; }
template <typename T, typename U> Modular<T> operator-(const Modular<T>& lhs, U rhs) { return Modular<T>(lhs) -= rhs; }
template <typename T, typename U> Modular<T> operator-(U lhs, const Modular<T>& rhs) { return Modular<T>(lhs) -= rhs; }

template <typename T> Modular<T> operator*(const Modular<T>& lhs, const Modular<T>& rhs) { return Modular<T>(lhs) *= rhs; }
template <typename T, typename U> Modular<T> operator*(const Modular<T>& lhs, U rhs) { return Modular<T>(lhs) *= rhs; }
template <typename T, typename U> Modular<T> operator*(U lhs, const Modular<T>& rhs) { return Modular<T>(lhs) *= rhs; }

template <typename T> Modular<T> operator/(const Modular<T>& lhs, const Modular<T>& rhs) { return Modular<T>(lhs) /= rhs; }
template <typename T, typename U> Modular<T> operator/(const Modular<T>& lhs, U rhs) { return Modular<T>(lhs) /= rhs; }
template <typename T, typename U> Modular<T> operator/(U lhs, const Modular<T>& rhs) { return Modular<T>(lhs) /= rhs; }

template<typename T, typename U>
Modular<T> power(const Modular<T>& a, const U& b) {
  assert(b >= 0);
  Modular<T> x = a, res = 1;
  U p = b;
  while (p > 0) {
    if (p & 1) res *= x;
    x *= x;
    p >>= 1;
  }
  return res;
}

template <typename T>
bool IsZero(const Modular<T>& number) {
  return number() == 0;
}

template <typename T>
string to_string(const Modular<T>& number) {
  return to_string(number());
}

template <typename T>
std::ostream& operator<<(std::ostream& stream, const Modular<T>& number) {
  return stream << number();
}

template <typename T>
std::istream& operator>>(std::istream& stream, Modular<T>& number) {
  typename common_type<typename Modular<T>::Type, int64_t>::type x;
  stream >> x;
  number.value = Modular<T>::normalize(x);
  return stream;
}

/*
using ModType = int;

struct VarMod { static ModType value; };
ModType VarMod::value;
ModType& md = VarMod::value;
using Mint = Modular<VarMod>;
*/

constexpr int md = (int) 1e9 + 7;
using Mint = Modular<std::integral_constant<decay<decltype(md)>::type, md>>;

template <typename T>
vector<vector<T>> operator*(const vector<vector<T>>& a, const vector<vector<T>>& b) {
  if (a.empty() || b.empty()) {
    return {{}};
  }
  vector<vector<T>> c(a.size(), vector<T>(b[0].size()));
  for (int i = 0; i < static_cast<int>(c.size()); i++) {
    for (int j = 0; j < static_cast<int>(c[0].size()); j++) {
      c[i][j] = 0;
      for (int k = 0; k < static_cast<int>(b.size()); k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  return c;
}

template <typename T>
vector<vector<T>>& operator*=(vector<vector<T>>& a, const vector<vector<T>>& b) {
  return a = a * b;
}

template <typename T, typename U>
vector<vector<T>> power(const vector<vector<T>>& a, const U& b) {
  assert(b >= 0);
  vector<U> binary;
  U bb = b;
  while (bb > 0) {
    binary.push_back(bb & 1);
    bb >>= 1;
  }
  vector<vector<T>> res(a.size(), vector<T>(a.size()));
  for (int i = 0; i < static_cast<int>(a.size()); i++) {
    res[i][i] = 1;
  }
  for (int j = (int) binary.size() - 1; j >= 0; j--) {
    res *= res;
    if (binary[j] == 1) {
      res *= a;
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> x(m + 1);
  for (int i = 0; i < m; i++) {
    cin >> x[i];
  }
  x[m] = n + 1;
  int ptr = 0;
  Mint s0 = 1, s1 = 0, s2 = 0;
  Mint f = 0;
  vector<Mint> rf(3);
  vector<Mint> rs0(3);
  vector<Mint> rs1(3);
  vector<Mint> rs2(3);
  int idle = 0;
  for (int i = 1; i <= n; i++) {
    if (x[ptr] == i) {
      ++ptr;
      idle = 0;
      continue;
    }
    f = s2 + (s0 * i - s1 * 2) * i;
    s0 += f;
    s1 += f * i;
    s2 += f * i * i;
    rf[i % 3] = f;
    rs0[i % 3] = s0;
    rs1[i % 3] = s1;
    rs2[i % 3] = s2;
    ++idle;
    if (idle >= 3) {
      int extra = x[ptr] - 1 - i;
      vector<vector<Mint>> mat = {{0, 0, 1}, {1, 0, -2}, {0, 1, 4}};
      mat = power(mat, extra);
      vector<Mint> fs(3);
      for (int j = 0; j < 3; j++) {
        fs[j] = rf[i % 3] * mat[2][j] + rf[(i + 2) % 3] * mat[1][j] + rf[(i + 1) % 3] * mat[0][j];
      }
      i += extra;
      // fs[0] = s2 + s0 * (i - 2) * (i - 2) - 2 * (i - 2) * s1
      // fs[1] = (s2 + fs[0] * (i - 2) * (i - 2)) + (s0 + fs[0]) * (i - 1) * (i - 1) - 2 * (i - 1) * (s1 + fs[0] * (i - 2))
      // fs[2] = (s2 + fs[0] * (i - 2) * (i - 2) + fs[1] * (i - 1) * (i - 1)) + (s0 + fs[0] + fs[1]) * i * i - 2 * i * (s1 + fs[0] * (i - 2) + fs[1] * (i - 1))
      mat = {{Mint(i - 2) * (i - 2), -Mint(2) * (i - 2), 1},
             {Mint(i - 1) * (i - 1), -Mint(2) * (i - 1), 1},
             {Mint(i) * i, -Mint(2) * i, 1}};
      vector<Mint> R = {fs[0],
                        fs[1] - fs[0] * (i - 2) * (i - 2) - fs[0] * (i - 1) * (i - 1) + 2 * fs[0] * (i - 1) * (i - 2),
                        fs[2] - fs[0] * (i - 2) * (i - 2) - fs[1] * (i - 1) * (i - 1) - (fs[0] + fs[1]) * i * i + 2 * i * (fs[0] * (i - 2) + fs[1] * (i - 1))};
      Mint inv_det = 1 / (mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) +
                          mat[0][1] * (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) +
                          mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]));
      s0 = (  R[0]    * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) +
            mat[0][1] * (mat[1][2] *   R[2]    -   R[1]    * mat[2][2]) +
            mat[0][2] * (  R[1]    * mat[2][1] - mat[1][1] *   R[2]   )) * inv_det;
      s1 = (mat[0][0] * (  R[1]    * mat[2][2] - mat[1][2] *   R[2]   ) +
              R[0]    * (mat[1][2] * mat[2][0] - mat[1][0] * mat[2][2]) +
            mat[0][2] * (mat[1][0] *   R[2]    -   R[1]    * mat[2][0])) * inv_det;
      s2 = (mat[0][0] * (mat[1][1] *   R[2]    -   R[1]    * mat[2][1]) +
            mat[0][1] * (  R[1]    * mat[2][0] - mat[1][0] *   R[2]   ) +
              R[0]    * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0])) * inv_det;
      s0 += fs[0] + fs[1] + fs[2];
      s1 += fs[0] * (i - 2) + fs[1] * (i - 1) + fs[2] * i;
      s2 += fs[0] * (i - 2) * (i - 2) + fs[1] * (i - 1) * (i - 1) + fs[2] * i * i;
      f = fs[2];
    }
  }
  cout << f << '\n';
  return 0;
}


Measured memory_bytes: 640