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++ (Clang 10.0.0) (judge verdict: Accepted)

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define int long long
int mod = 1000000007;
using namespace std;
int n;
struct stst{
	long long a[4][4];
	stst() {
		memset (a, 0, sizeof a);
	}
	void build () {
		for (int i = 1; i <= 3; i++) a[i][i] = 1;
	}
}a;
stst operator *(const stst &x, const stst &y){
	stst z;
	for (int k = 1; k <= 3; k++)
		for (int i = 1; i <= 3; i++)
			for (int j = 1; j <= 3; j++)
				z.a[i][j] = (z.a[i][j] + x.a[i][k] * y.a[k][j] % mod) % mod;
	return z;
}
stst quickmod (stst a, long long b) {
	stst ans;
	ans.build ();
	while (b) {
		if (b & 1) ans = ans * a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}
long long k;
long long b[100005];
signed main () {
	scanf ("%lld %lld", &n, &k);
	for (int i = 1; i <= k; i++) scanf ("%lld", &b[i]);
	stst ans;
	ans.build();
	stst x, y;
	x.a[1][1] = 1, x.a[1][2] = 2, x.a[1][3] = 1;
	x.a[2][2] = 1, x.a[2][3] = 1, x.a[3][3] = 1;
	
	y.a[1][1] = 2, y.a[1][2] = 2, y.a[1][3] = 1;
	y.a[2][1] = 1, y.a[2][2] = 1, y.a[2][3] = 1;
	y.a[3][1] = 1, y.a[3][2] = 0, y.a[3][3] = 1;
	
	int last = 0;
	for (int i = 1; i <= k; i++) {
		int len = b[i] - last - 1;
		if (len > 0) ans = ans * quickmod (y, len);
		ans = ans * x;
		last = b[i];
	}
	int len = n - last - 1;
	if (len > 0) ans = ans * quickmod (y, len);
	printf ("%lld", (ans.a[1][1] + ans.a[1][2] + ans.a[1][3]) % mod);
	return 0;
}