Problem:
Score : 1600 points

Problem Statement

Joisino has a bar of length N, which has M marks on it.
The distance from the left end of the bar to the i-th mark is X_i.

She will place several squares on this bar.
Here, the following conditions must be met:

Only squares with integral length sides can be placed.

Each square must be placed so that its bottom side touches the bar.

The bar must be completely covered by squares.
That is, no square may stick out of the bar, and no part of the bar may be left uncovered.

The boundary line of two squares may not be directly above a mark.

Examples of arrangements that satisfy/violate the conditions

The beauty of an arrangement of squares is defined as the product of the areas of all the squares placed.
Joisino is interested in the sum of the beauty over all possible arrangements that satisfy the conditions.
Write a program to find it.
Since it can be extremely large, print the sum modulo 10^9+7.

Constraints

All input values are integers.

1 \leq N \leq 10^9

0 \leq M \leq 10^5

1 \leq X_1 < X_2 < ... < X_{M-1} < X_M \leq N-1

Input

Input is given from Standard Input in the following format:

N M
X_1 X_2 ... X_{M-1} X_M

Output

Print the sum of the beauty over all possible arrangements that satisfy the conditions, modulo 10^9+7.

Sample Input 1

3 1
2

Sample Output 1

13

There are two possible arrangements:

Place a square of side length 1 to the left, and place another square of side length 2 to the right

Place a square of side length 3

The sum of the beauty of these arrangements is (1 \times 1 \times 2 \times 2) + (3 \times 3) = 13.

Sample Input 2

5 2
2 3

Sample Output 2

66

Sample Input 3

10 9
1 2 3 4 5 6 7 8 9

Sample Output 3

100

Sample Input 4

1000000000 0

Sample Output 4

693316425

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 3 * 1000 * 100 + 47;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;


int A[4][4] =
{
    {1, 0, 0, 1},
    {1, 1, 0, 1},
    {1, 0, 1, 1},
    {1, 1, 1, 2}
};

int B[4][4] =
{
    {1, 0, 0, 0},
    {1, 1, 0, 0},
    {1, 0, 1, 0},
    {1, 1, 1, 1}
};

struct vect
{
    int A[4];
    vect()
    {
        FILL(A, 0);
    }
};

struct matrix
{
    int A[4][4];
    
    matrix()
    {
        FILL(A, 0);
    }
    
    matrix operator*(const matrix &m) const
    {
        matrix M;
        FOR(i, 0, 4)
            FOR(j, 0, 4)
                FOR(k, 0, 4)
                    M.A[i][j] = (M.A[i][j] + A[i][k] * 1LL* m.A[k][j]) % MOD;
        return M;
    }
    vect operator * (const vect& v) const
    {
        vect V;
        FOR(i, 0, 4)
            FOR(j, 0, 4)
                V.A[i] = (V.A[i] + A[i][j] * 1LL * v.A[j]) % MOD;
        return V;
    }
};


matrix BP(matrix M, int n)
{
    matrix RES;
    FOR(i, 0, 4)RES.A[i][i] = 1;
    while(n)
    {
        if (n & 1)RES = RES * M;
        M = M * M;
        n >>=1;
    }
    return RES;
}

int X[MAX];

int main()
{
    matrix A, B;
    FOR(i, 0, 4)FOR(j, 0, 4)A.A[i][j] = ::A[i][j];
    FOR(i, 0, 4)FOR(j, 0, 4)B.A[i][j] = ::B[i][j];
    
    int n, m;
    scanf("%d%d", &n, &m);
    FOR(i, 0, m)
    scanf("%d", X + i);
    X[m++] = n;
    
    vect V;
    V.A[0] = 1;
    FOR(i, 0, m)
    {
        matrix M = BP(A, X[i] - (i ? X[i-1] : 0) - 1);
        V = (M * B) * V;
    }
    cout << V.A[3] << endl;
    
    
    
}