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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

struct mat{
	ll t[4][4];
	mat operator-(const mat &l){
		mat r = {};
		for(int i = 0; i <4; i++){
			for(int j = 0; j < 4; j++){
				r.t[i][j] = (t[i][j] - l.t[i][j] + MM) % MM;
			}
		}
		return r;
	}
	mat operator*(const mat &l){
		mat r = {};
		for(int k = 0; k < 4; k++){
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					r.t[i][j] = (r.t[i][j] + t[i][k] * l.t[k][j]) % MM;
				}
			}
		}
		return r;
	}
};

mat DB = {{
	{0, 0, MM-1, 2},
	{0, 1, MM-1, 2},
	{0, 1, 0, 2},
	{0, 1, 0, 3}
}};

mat pw(mat A, int x){
	mat R = {};
	for(int i = 0; i < 4; i++) R.t[i][i] = 1;

	while(x){
		if( x&1 ) R = R*A;
		A = A*A; x /= 2;
	}
	return R;
}

ll get(int x){
	mat R = pw(DB, x);

	return (R.t[0][0] + R.t[0][1] + R.t[0][2] + R.t[0][3]) % MM;
}

ll A[MX], B[MX];

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++) scanf("%lld", A+i); A[++M] = N;

	mat cur = {};

	for(int i = 1; i <= M; i++){
		mat R = pw(DB, A[i]) - cur;
		B[i] = (R.t[0][0] + R.t[0][1] + R.t[0][2] + R.t[0][3]) % MM;
		for(int t = 0; t < 4; t++) cur.t[t][t] = (cur.t[t][t] + B[i]) % MM;
		cur = cur * pw(DB, A[i+1] - A[i]);
	}
	printf("%lld\n", B[M]);
}