#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif


#define DEFMOD(mod, type) typedef ModInt<mod, int> type;     \
                          type operator "" _m(unsigned long long x) {   \
                              type res = x; return res; \
                          }

template<int mod, class itype> struct ModInt {
    int val;
    ModInt() {
        val = 0;
    }
    ModInt(int a) {
        val = a % mod;
    }
};

/* MODIFY AS NEEDED */

DEFMOD(1000000007, mi)

template<int mod, class itype> ModInt<mod, itype> fpow(ModInt<mod, itype> base, int exponent)
{
    ModInt<mod, itype> ans = 1_m;
    ModInt<mod, itype> cur = base;
    while (exponent) {
        if (exponent & 1) ans = ans * cur;
        cur = cur * cur; exponent >>= 1;
    }
    return ans;
}

template<int mod, class itype> ModInt<mod, itype> operator+(ModInt<mod, itype> a, ModInt<mod, itype> b)
{
    ModInt<mod, itype> ans;
    ll val = (ll)(a.val) + (ll)(b.val);
    if (val >= mod) val -= mod;
    ans.val = val; return ans;
}

template<int mod, class itype> ModInt<mod, itype> operator-(ModInt<mod, itype> a, ModInt<mod, itype> b)
{
    ModInt<mod, itype> ans;
    ans.val = a.val - b.val;
    if (ans.val < 0) ans.val += mod;
    return ans;
}

template<int mod, class itype> ModInt<mod, itype> operator*(ModInt<mod, itype> a, ModInt<mod, itype> b)
{
    ModInt<mod, itype> ans;
    ans.val = ((ll)(a.val) * (ll)(b.val)) % (ll)mod;
    return ans;
}

// PRIME MOD ONLY!
template<int mod, class itype> ModInt<mod, itype> operator/(ModInt<mod, itype> a, ModInt<mod, itype> b)
{
#ifndef ONLINE_JUDGE
    if (b.val == 0) {
        fprintf(stderr, "Division by zero :(\n"); abort();
    }
#endif
    return a * fpow(b, mod - 2);
}


template<int r, int c, class T> struct Matrix {
    T a[r+1][c+1];
    Matrix() {
        for (int i = 1; i <= r; i++) {
            for (int j = 1; j <= c; j++) {
                a[i][j] = 0;
            }
        }
    }
};

template<int r, int c, int k, class T>
void matrix_mult(Matrix<r, k, T>& ans, const Matrix<r, c, T>& first,
    const Matrix<c, k, T>& second) {
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= k; j++) {
            ans.a[i][j] = 0;
        }
    }
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= k; j++) {
            for (int x = 1; x <= c; x++) {
                ans.a[i][j] = ans.a[i][j] + first.a[i][x] * second.a[x][j];
            }
        }
    }
}

template<int n, class T>
void matrix_power(Matrix<n, n, T>& base, ll exponent)
{
    Matrix<n, n, T> cur = base;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            base.a[i][j] = (i == j ? 1 : 0);
        }
    }
    while (exponent) {
        Matrix<n, n, T> tmp;
        if (exponent & 1LL) {
            matrix_mult(tmp, base, cur);
            base = tmp;
        }
        matrix_mult(tmp, cur, cur);
        cur = tmp; exponent >>= 1LL;
    }
}

Matrix<4, 1, mi> ans;
Matrix<4, 4, mi> trans;
Matrix<4, 4, mi> trans_mark;

int n, m;
int x[100005];

int main()
{
    ans.a[1][1] = 1_m;
    trans.a[1][1] = 1_m; trans.a[1][2] = 2_m; trans.a[1][3] = 1_m; trans.a[1][4] = 1_m;
    trans.a[2][1] = 1_m; trans.a[2][2] = 1_m; trans.a[2][3] = 1_m; trans.a[2][4] = 0_m;
    trans.a[3][1] = 1_m; trans.a[3][2] = 0_m; trans.a[3][3] = 1_m; trans.a[3][4] = 0_m;
    trans.a[4][1] = 1_m; trans.a[4][2] = 2_m; trans.a[4][3] = 1_m; trans.a[4][4] = 1_m;
    trans_mark.a[1][1] = 0_m; trans_mark.a[1][2] = 0_m; trans_mark.a[1][3] = 0_m; trans_mark.a[1][4] = 0_m;
    trans_mark.a[2][1] = 1_m; trans_mark.a[2][2] = 1_m; trans_mark.a[2][3] = 1_m; trans_mark.a[2][4] = 0_m;
    trans_mark.a[3][1] = 1_m; trans_mark.a[3][2] = 0_m; trans_mark.a[3][3] = 1_m; trans_mark.a[3][4] = 0_m;
    trans_mark.a[4][1] = 1_m; trans_mark.a[4][2] = 2_m; trans_mark.a[4][3] = 1_m; trans_mark.a[4][4] = 1_m;

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) scanf("%d", x + i);
    int cur = 0;
    for (int i = 1; i <= m; i++) {
        Matrix<4, 4, mi> tmp = trans;
        Matrix<4, 1, mi> tmp2;
        matrix_power(tmp, x[i] - cur - 1);
        matrix_mult(tmp2, tmp, ans);
        matrix_mult(ans, trans_mark, tmp2);
        cur = x[i];
    }
    Matrix<4, 4, mi> tmp = trans;
    Matrix<4, 1, mi> final_ans;
    matrix_power(tmp, n - cur);
    matrix_mult(final_ans, tmp, ans);
    printf("%d", final_ans.a[1][1].val);
    return 0;
}


Measured memory_bytes: 3484