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<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0; char ch=gc(); bool positive=1;
	for (;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for (;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(int a){
    if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	if(a<0){
		a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=3,mod=1000000007;
struct matrix{
	int a[N][N];
	inline int* operator [] (int x){
        return a[x];
    }
	void clear(){
    	memset(a,0,sizeof(a));
	}
}zs,ans,md;
matrix operator *(matrix a,matrix b){
	matrix tmp; tmp.clear();
	for(int i=0;i<3;i++){for(int k=0;k<3;k++){
		
			for(int j=0;j<3;j++){
				tmp[i][j]=(tmp[i][j]+(ll)a[i][k]*b[k][j])%mod;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix zs,int k){
	matrix ans; ans.clear(); for(int i=0;i<3;i++)ans[i][i]=1;
	for(;k;k>>=1){
		if(k&1)ans=ans*zs;
		zs=zs*zs;
	}
	return ans;
}
int n,m,a[100005];
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++)a[i]=read()+1;
	zs[0][0]=1; zs[0][1]=2;
	zs[0][2]=1; zs[1][1]=1; zs[1][2]=1;
	zs[2][0]=1; zs[2][1]=2; zs[2][2]=2;
	md=zs; md[2][0]=md[2][1]=0; md[2][2]=1;
	for(int i=0;i<3;i++)ans[i][i]=1;
	for(int i=1;i<=m;i++){
		ans=ans*ksm(zs,a[i]-a[i-1]-1);
		ans=ans*md;
	}
	//cout<<ans[0][0]<<" "<<ans[0][1]<<" "<<ans[0][2]<<endl;
	ans=ans*ksm(zs,n-a[m]);
	cout<<ans[0][2]<<endl;
}