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++ (GCC 9.2.1) (judge verdict: Accepted)

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 1000000
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}

struct Matrix{
	int ma[3][3];
	Matrix(){mem(ma,0);}
	int* operator [](int i) { return ma[i]; }
};
Matrix operator*(Matrix A,Matrix B){
	Matrix C;
	for(int k=0;k<3;k++)
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
			C[i][j]=add(C[i][j],mul(A[i][k],B[k][j]));
	return C;
}
Matrix fst_pow(Matrix A,int b){
	Matrix res;
	for(int i=0;i<3;i++)res[i][i]=1;
	while(b){
		if(b&1)res=res*A;
		A=A*A,b>>=1;
	}
	return res;
}
int n,m,lst;
Matrix A,B;

int main(){
	n=read(),m=read();

	A[0][0]=2,A[0][1]=1,A[0][2]=1;
	A[1][0]=2,A[1][1]=1,A[1][2]=0;
	A[2][0]=1,A[2][1]=1,A[2][2]=1;

	B[0][0]=1,B[0][1]=0,B[0][2]=0;
	B[1][0]=2,B[1][1]=1,B[1][2]=0;
	B[2][0]=1,B[2][1]=1,B[2][2]=1;

	Matrix res;
	res[0][0]=1;
	for(int i=1;i<=m;i++){
		int x=read();
		res=fst_pow(A,x-lst-1)*res;
		res=B*res;
		lst=x;
	}
	res=fst_pow(A,n-lst)*res;
	printf("%d\n",res[2][0]);
}