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<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int D=4,P=1000000007;
int i,j,k,n,m,ff,ch,lt,nw;
struct matrix {
	int a[D][D];
	void clear() {
		memset(a,0,sizeof a);
	}
	matrix operator * (const matrix &n) const {
		int i,j,k;
		matrix t;
		t.clear();
		for (i=0;i<D;i++)
			for (j=0;j<D;j++) {
				ll tt=0;
				for (k=0;k<D;k++) tt+=(ll) a[i][k]*n.a[k][j];
				t.a[i][j]=tt%P;
			}
		return t;
	}
} A[32],B;
struct cc {
	int a[D];
	void clear() {
		memset(a,0,sizeof a);
	}
	cc operator * (const matrix &n) const {
		int j,k;
		cc t;
		t.clear();
		for (j=0;j<D;j++) {
			ll tt=0;
			for (k=0;k<D;k++) tt+=(ll) a[k]*n.a[k][j];
			t.a[j]=tt%P;
		}
		return t;
	}
} ans;
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void pre() {
	int i,j,k;
	for (i=0;i<D;i++)
		for (j=0;j<D;j++) if ((i|j)==i) {
			A[0].a[i][j]=1;
			B.a[i][j]=1;
		}
	for (i=0;i<D;i++) A[0].a[i][3]++;
	for (i=1;i<=30;i++) A[i]=A[i-1]*A[i-1];
}
int main() {
	ans.a[3]=1;
	pre();
	R(n);R(m);
	lt=0;
	for (i=1;i<=m;i++) {
		R(nw);
		for (k=nw-lt-1,j=0;k;k>>=1,j++) if (k&1) ans=ans*A[j];
		ans=ans*B;
		lt=nw;
	}
	for (k=n-lt-1,j=0;k;k>>=1,j++) if (k&1) ans=ans*A[j];
	int Ans=((ll) ans.a[0]+ans.a[1]+ans.a[2]+ans.a[3])%P;
	printf("%d\n",Ans);
}