#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define MAXN 10500

int64 v[MAXN];
int n;
int64 memo[MAXN][2];

int64 calcula2(int ind, int a) {

	if (memo[ind][a] != -1) return memo[ind][a];

	int64 res = 0;
	if (a == 1) {
		if (v[ind] % 2 == 0) {
			return memo[ind][a] = calcula2(ind+1, a) + 1;
		}
		else {
			return memo[ind][a] = 0;
		}
	}
	if (a == 0) {
		if (ind == 0) {
			if (v[0] % 2 == 0) {
				return memo[ind][a] = calcula2(ind+1, 1) + 1;
			}
			else {
				return memo[ind][a] = 0;
			}
		}
		int y;
		if (v[ind-1] % 2 == 0) y = v[ind-1] - 1;
		else y = v[ind-1];
		res = calcula2(ind-1, 0) + y;
		if (v[ind-1] % 2 == 0) y = v[ind-1];
		else y = v[ind-1] - 1;
		res = max(res, calcula2(ind, 1) + y);

		return memo[ind][a] = res;
	}
}

int64 calcula(int ind, int a) {

	if (memo[ind][a] != -1) return memo[ind][a];

	int64 res = 0;
	if (a == 1) {
		if (v[ind-1] % 2 == 0) {
			return memo[ind][a] = calcula(ind-1, a) + 1;
		}
		else {
			return memo[ind][a] = 0;
		}
	}
	if (a == 0) {
		if (ind == n-1) {
			if (v[n-2] % 2 == 0) {
				return memo[ind][a] = calcula(ind-1, 1) + 1;
			}
			else {
				return memo[ind][a] = 0;
			}
		}
		int y;
		if (v[ind] % 2 == 0) y = v[ind] - 1;
		else y = v[ind];
		res = calcula(ind+1, 0) + y;
		if (v[ind] % 2 == 0) y = v[ind];
		else y = v[ind] - 1;
		res = max(res, calcula(ind, 1) + y);

		return memo[ind][a] = res;
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n-1; i++) cin >> v[i];
	memset(memo, -1, sizeof(memo));
	int64 res;
	int64 first, last;
	first = v[0];
	last = v[n-2];
	v[0] = 1;
	res = calcula(1, 0) + first;

	memset(memo, -1, sizeof(memo));
	v[0] = first;
	v[n-2] = 1;
	res = max(res, calcula2(n-2, 0) + last);
	cout << res;
	printf("\n");
	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define MAXN 100500

int64 v[MAXN];

int64 leftt[MAXN];
int64 rightt[MAXN];
int64 sum[MAXN];
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n-1; i++) {
		cin >> v[i];
	}
	leftt[0] = 0;
	int y;
	for (int i = 1; i < n; i++) {
		if (v[i-1] == 1) leftt[i] = 0;
		else {
			if (v[i-1] % 2 == 0) y= v[i-1];
			else y = v[i-1] - 1;
			leftt[i] = leftt[i-1]	+ y;
		}
	}
	rightt[n-1] = 0;
	for (int i = n-2; i >= 0; i--) {
		if (v[i] == 1) rightt[i] = 0;
		else {
			if (v[i] % 2 == 0) y = v[i];
			else y = v[i] - 1;
			rightt[i] = rightt[i+1] + y;
		}
	}
	sum[0] = 0;
	for (int i = 1; i < n; i++) {
		if (v[i-1] % 2 == 0) y = v[i-1] - 1;
		else y = v[i-1];
		sum[i] = sum[i-1] + y;
	}
	int64 res = 0;
	int64 maior = 0;
	maior = 0;
	for (int j = 0; j < n; j++) {
		maior = max(maior, leftt[j] - sum[j]);
		res = max(res, sum[j] + rightt[j] + maior);
	}
	cout << res;
	printf("\n");
	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define MAXN 10500

int64 v[MAXN];

int64 leftt[MAXN];
int64 rightt[MAXN];
int64 sum[MAXN];
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n-1; i++) {
		cin >> v[i];
	}
	leftt[0] = 0;
	int y;
	for (int i = 1; i < n; i++) {
		if (v[i-1] == 1) leftt[i] = 0;
		else {
			if (v[i-1] % 2 == 0) y= v[i-1];
			else y = v[i-1] - 1;
			leftt[i] = leftt[i-1]	+ y;
		}
	}
	rightt[n-1] = 0;
	for (int i = n-2; i >= 0; i--) {
		if (v[i] == 1) rightt[i] = 0;
		else {
			if (v[i] % 2 == 0) y = v[i];
			else y = v[i] - 1;
			rightt[i] = rightt[i+1] + y;
		}
	}
	sum[0] = 0;
	for (int i = 1; i < n; i++) {
		if (v[i-1] % 2 == 0) y = v[i-1] - 1;
		else y = v[i-1];
		sum[i] = sum[i-1] + y;
	}
	int64 res = 0;
	int64 maior = 0;
	maior = 0;
	for (int j = 0; j < n; j++) {
		maior = max(maior, leftt[j] - sum[j]);
		res = max(res, sum[j] + rightt[j] + maior);
	}
	cout << res;
	printf("\n");
	return 0;
}


/****************************************************************
	Problem: CF #127 E
	User: Jeflie
	Language: C++
	Result: Accepted
	Time: 170 ms
	Memory: 5400 kb
****************************************************************/

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

long long a[100010];
long long dp_left[100010][2], dp_right[100010][2];
// dp_left[i][0]��ʾ��i�ڵ㿪ʼ�����ߣ���Զ���߶��ٲ�
// dp_left[i][1]��ʾ��i�ڵ㿪ʼ�����ߣ������ջص�i�㣬��Զ���߶��ٲ�

int main()
{
    long long n;
    cin>>n;
    for (long long i = 1; i < n; i++)
        cin>>a[i];

    dp_left[1][0] = dp_left[1][1] = 0;
    for (long long i = 2; i <= n; i++)
    {
        if (a[i-1] >= 2)
            dp_left[i][1] = dp_left[i-1][1] + a[i-1]/2*2;
        if (a[i-1]%2)
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1], dp_left[i-1][1] + a[i-1]);
        else
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1] - 1, dp_left[i-1][1] + a[i-1] - 1);
    }

    dp_right[n][0] = dp_right[n][1] = 0;
    for (long long i = n-1; i >= 1; i--)
    {
        if (a[i] >= 2)
            dp_right[i][1] = dp_right[i+1][1] + a[i]/2*2;
        if (a[i]%2)
            dp_right[i][0] = max(dp_right[i+1][0] + a[i], dp_right[i+1][1] + a[i]);
        else
            dp_right[i][0] = max(dp_right[i+1][0] + a[i] - 1, dp_right[i+1][1] + a[i] - 1);
    }

    long long Max = 0;
    for (long long i = 1; i <= n; i++)
    {
        Max = max(Max, dp_left[i][1] + dp_right[i][0]);
        Max = max(Max, dp_left[i][0] + dp_right[i][1]);
    }
    cout<<Max<<endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int a[100010];
int dp_left[100010][2], dp_right[100010][2];

int main()
{
    int n;
    cin>>n;
    for (int i = 1; i < n; i++)
        cin>>a[i];

    dp_left[1][0] = dp_left[1][1] = 0;
    for (int i = 2; i <= n; i++)
    {
        if (a[i-1] >= 2)
            dp_left[i][1] = dp_left[i-1][1] + a[i-1]/2*2;
        if (a[i-1]%2)
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1], dp_left[i-1][1] + a[i-1]);
        else
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1] - 1, dp_left[i-1][1] + a[i-1] - 1);
    }

    dp_right[n][0] = dp_right[n][1] = 0;
    for (int i = n-1; i >= 1; i--)
    {
        if (a[i] >= 2)
            dp_right[i][1] = dp_right[i+1][1] + a[i]/2*2;
        if (a[i]%2)
            dp_right[i][0] = max(dp_right[i+1][0] + a[i], dp_right[i+1][1] + a[i]);
        else
            dp_right[i][0] = max(dp_right[i+1][0] + a[i] - 1, dp_right[i+1][1] + a[i] - 1);
    }

    int Max = 0;
    for (int i = 1; i <= n; i++)
    {
        Max = max(Max, dp_left[i][0]);
        Max = max(Max, dp_right[i][0]);
        Max = max(Max, dp_left[i][1] + dp_right[i][0]);
        Max = max(Max, dp_left[i][0] + dp_right[i][1]);
    }
    cout<<Max<<endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

long long a[100010];
long long dp_left[100010][2], dp_right[100010][2];

int main()
{
    long long n;
    cin>>n;
    for (long long i = 1; i < n; i++)
        cin>>a[i];

    dp_left[1][0] = dp_left[1][1] = 0;
    for (long long i = 2; i <= n; i++)
    {
        if (a[i-1] >= 2)
            dp_left[i][1] = dp_left[i-1][1] + a[i-1]/2*2;
        if (a[i-1]%2)
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1], dp_left[i-1][1] + a[i-1]);
        else
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1] - 1, dp_left[i-1][1] + a[i-1] - 1);
    }

    dp_right[n][0] = dp_right[n][1] = 0;
    for (long long i = n-1; i >= 1; i--)
    {
        if (a[i] >= 2)
            dp_right[i][1] = dp_right[i+1][1] + a[i]/2*2;
        if (a[i]%2)
            dp_right[i][0] = max(dp_right[i+1][0] + a[i], dp_right[i+1][1] + a[i]);
        else
            dp_right[i][0] = max(dp_right[i+1][0] + a[i] - 1, dp_right[i+1][1] + a[i] - 1);
    }

    long long Max = 0;
    for (long long i = 1; i <= n; i++)
    {
        Max = max(Max, dp_left[i][0]);
        Max = max(Max, dp_right[i][0]);
        Max = max(Max, dp_left[i][1] + dp_right[i][0]);
        Max = max(Max, dp_left[i][0] + dp_right[i][1]);
    }
    cout<<Max<<endl;
    return 0;
}


/****************************************************************
	Problem: CF #127 E
	User: Jeflie
	Language: C++
	Result: Accepted
	Time: 170 ms
	Memory: 5400 kb
****************************************************************/

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

long long a[100010];
long long dp_left[100010][2], dp_right[100010][2];
// dp_left[i][0]��ʾ��i�ڵ㿪ʼ�����ߣ���Զ���߶��ٲ�
// dp_left[i][1]��ʾ��i�ڵ㿪ʼ�����ߣ������ջص�i�㣬��Զ���߶��ٲ�

int main()
{
    memset(dp_left, 0, sizeof(dp_left));
    memset(dp_right, 0, sizeof(dp_right));
    long long n;
    cin>>n;
    for (long long i = 1; i < n; i++)
        cin>>a[i];

    dp_left[1][0] = dp_left[1][1] = 0;
    for (long long i = 2; i <= n; i++)
    {
        if (a[i-1] >= 2)
            dp_left[i][1] = dp_left[i-1][1] + a[i-1]/2*2;
        if (a[i-1]%2)
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1], dp_left[i-1][1] + a[i-1]);
        else
            dp_left[i][0] = max(dp_left[i-1][0] + a[i-1] - 1, dp_left[i-1][1] + a[i-1] - 1);
    }

    dp_right[n][0] = dp_right[n][1] = 0;
    for (long long i = n-1; i >= 1; i--)
    {
        if (a[i] >= 2)
            dp_right[i][1] = dp_right[i+1][1] + a[i]/2*2;
        if (a[i]%2)
            dp_right[i][0] = max(dp_right[i+1][0] + a[i], dp_right[i+1][1] + a[i]);
        else
            dp_right[i][0] = max(dp_right[i+1][0] + a[i] - 1, dp_right[i+1][1] + a[i] - 1);
    }

    long long Max = 0;
    for (long long i = 1; i <= n; i++)
    {
        Max = max(Max, dp_left[i][1] + dp_right[i][0]);  // �������ߣ��ص�����������
        Max = max(Max, dp_left[i][0] + dp_right[i][1]);  // �������ߣ��ص�����������
    }
    cout<<Max<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, j, k) for (int i = j; i <= k; i ++)
#define FORD(i, j, k) for (int i = j; i >= k; i --)
#define mn 1000006
#define maxC 1000000007
#define pb push_back
#define F first
#define S second
#define mp make_pair

using namespace std;
int n, a[mn], odd[mn], even[mn];
long long lef[mn], rig[mn], sumOdd[mn], best = 0, ans = 0;

void setup()
{
    cin >> n;
    FOR(i, 2, n)
    {
        cin >> a[i];
        if (a[i] & 1)
            odd[i] = a[i], even[i] = a[i] - 1;
        else
            odd[i] = a[i] - 1, even[i] = a[i];
        sumOdd[i] = sumOdd[i - 1] + odd[i];
    }
}

void xuly()
{
    FOR(i, 2, n)
    if (a[i] == 1)
        lef[i] = 0;
    else
        lef[i] = even[i] + lef[i - 1];

    FORD(i, n - 1, 1)
    if (a[i + 1] == 1)
        rig[i] = 0;
    else
        rig[i] = even[i + 1] + rig[i + 1];

    FOR(i, 2, n)
    {
        best = max(best, lef[i] - sumOdd[i]);
        ans = max(ans, best + sumOdd[i] + rig[i]);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    setup ();
    xuly ();
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
template<class T> inline T Max(T a,T b)
{if(a>b)return a;else return b;}
template<class T> inline T Min(T a,T b)
{if(a<b)return a;else return b;}
template<class T> inline T gcd(T a,T b)
{if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)
{if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<class T> inline T TripleMax(T a,T b,T c)
{return Max(Max(a,b),c);}
template<class T> inline T TripleMin(T a,T b,T c)
{return Min(Min(a,b),c);}
#define PB push_back
#define MP make_pair
typedef long long ll;
const long double               pi = M_PI;
const long double               e = M_E;
const long double               sqrt2 = M_SQRT2;
const long long 		llinfinity = 9223372036854775807LL;
const long long 		llminusinfinity = -9223372036854775808LL;
const int                       intinfinity = 2147483647;
const int                       intminusinfinity = -2147483648;

const long long                 maxn = 100005;
ll              n;
ll              data[maxn];
ll              leftnum[maxn], rightnum[maxn];
ll              ret;
ll              numodd[maxn];
ll              largest;

inline ll odd (ll num) {
    if (num % 2 == 0) {
        return num - 1;
    } else {
        return num;
    }
}

inline ll even (ll num) {
    if (num % 2 == 0) {
        return num;
    } else {
        return num - 1;
    }
}

int main (int argc, const char* argv[]) {

    //freopen("data.in", "r", stdin);
    cin >> n;
    memset(data, 0, sizeof(data));
    memset(leftnum, 0, sizeof(leftnum));
    memset(rightnum, 0, sizeof(rightnum));
    memset(numodd, 0, sizeof(numodd));
    for (int i = 1; i < n; i++) {
        cin >> data[i];
    }
    for (int i = 2; i < n + 1; i++) {
        if (data[i - 1] == 1) {
            leftnum[i] = 0;
        } else {
            leftnum[i] = leftnum[i - 1] + even(data[i - 1]);
        }
    }
    for (int i = n - 1; i >= 1; i--) {
        if (data[i] == 1) {
            rightnum[i] = 0;
        } else {
            rightnum[i] = rightnum[i + 1] + even(data[i]);
        }
    }

    numodd[1] = 0;
    for (int i = 2; i < n + 1; i++) {
        numodd[i] = numodd[i - 1] + odd(data[i - 1]);
    }
    /*
    for (int i = 1; i < n + 1; i++) {
        cout << "numodd[i] = " << numodd[i] << endl;
    }
    */
    largest = llminusinfinity;
    ret = llminusinfinity;
    for (int i = 1; i < n + 1; i++) {
        ll              tmp1;
        ll              tmp2;
        tmp1 = rightnum[i] + numodd[i];
        tmp2 = leftnum[i] - numodd[i];
        if (tmp2 > largest) {
            largest = tmp2;
        }
        tmp1 += largest;
        if (tmp1 > ret) {
            ret = tmp1;
        }
    }
    cout << ret << endl;
    //fclose(stdin);
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
template<class T> inline T Max(T a,T b)
{if(a>b)return a;else return b;}
template<class T> inline T Min(T a,T b)
{if(a<b)return a;else return b;}
template<class T> inline T gcd(T a,T b)
{if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)
{if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<class T> inline T TripleMax(T a,T b,T c)
{return Max(Max(a,b),c);}
template<class T> inline T TripleMin(T a,T b,T c)
{return Min(Min(a,b),c);}
#define ll long long
#define PB push_back
#define MP make_pair

const int		maxn = 100005;
const ll		inf = 1LL << 50;
int				n;
ll				data[maxn];
//ll			data2[maxn];
//vector <ll>	numbers;

ll find (int l, int r) {
	//cout << "l = " << l << " r = " << r << endl;
	if (l > r) {
		return 0;
	}
	if (l == r) {
		return data[l];
	} else if (r - l == 1) {
		return Min(data[l], data[r]) * 2;
	} else {
		int		pt = l;
		ll		m = inf;
		for (int i = l; i < r + 1; i++) {
			if (data[i] < m) {
				m = data[i];
				pt = i;
			}
		}
		//cout << "m = " << m << " pt = " << pt << endl;
		return data[pt] + find(l, pt - 1) + find(pt + 1, r);
	}
}

int main (int argc, const char* argv[]) {

	memset(data, 0, sizeof(data));
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> data[i];
		//data2[i] = data[i];
	}
	/*
	sort(data2, data2 + n);
	numbers.clear();
	for (int i = 0; i < n; i++) {
		if (i == 0 || data2[i] != data2[i - 1]) {
			numbers.PB(data2[i]);
		}
	}
	*/
	cout << find (0, n - 2) << endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
template<class T> inline T Max(T a,T b)
{if(a>b)return a;else return b;}
template<class T> inline T Min(T a,T b)
{if(a<b)return a;else return b;}
template<class T> inline T gcd(T a,T b)
{if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)
{if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<class T> inline T TripleMax(T a,T b,T c)
{return Max(Max(a,b),c);}
template<class T> inline T TripleMin(T a,T b,T c)
{return Min(Min(a,b),c);}
#define ll long long
#define PB push_back
#define MP make_pair

const int		maxn = 100005;
const ll		inf = 1LL << 63;
int				n;
ll				data[maxn];
//ll			data2[maxn];
//vector <ll>	numbers;

ll find (int l, int r) {
	if (l > r) {
		return 0;
	}
	if (l == r) {
		return data[l];
	} else if (r - l == 1) {
		return Min(data[l], data[r]) * 2;
	} else {
		int		pt = l;
		ll		m = inf;
		for (int i = l; i < r + 1; i++) {
			if (data[i] < m) {
				m = data[i];
				pt = i;
			}
		}
		return data[pt] + find(l, pt - 1) + find(pt + 1, r);
	}
}

int main (int argc, const char* argv[]) {

	memset(data, 0, sizeof(data));
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> data[i];
		//data2[i] = data[i];
	}
	/*
	sort(data2, data2 + n);
	numbers.clear();
	for (int i = 0; i < n; i++) {
		if (i == 0 || data2[i] != data2[i - 1]) {
			numbers.PB(data2[i]);
		}
	}
	*/
	cout << find (0, n - 2) << endl;
    return 0;
}


#include <iostream>

using namespace std;
#define maxn 100009
typedef long long ll;

int n;

ll izq[maxn],der[maxn],impar[maxn];
ll num[maxn];

ll maxpar(ll value)
{
    return value - value % 2;
}

ll maximpar(ll value)
{
    if(value % 2)return value;
    else
        return value - 1;
}

ll suma(int i, int j)
{
    return impar[j] - impar[i];
}

int main()
{
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        cin >> num[i];
    }

    for(int i = 2; i <= n; i++)
    {
        izq[i] = izq[i - 1] + maxpar(num[i - 1]);
        if(num[i - 1] == 1)izq[i] = 0;
    }

    for(int i = n - 1; i >= 1; i--)
    {
        der[i] = der[i + 1] + maxpar(num[i]);
        if(num[i] == 1)der[i] = 0;
    }

    for(int i = 2; i <= n; i++)
    {
        impar[i] = impar[i - 1] + maximpar(num[i - 1]);
    }

    ll t = 0;
    ll res = 0;
    for(int j = 1; j <= n; j++)
    {
        t = max(t, izq[j] - impar[j]);
        res = max(res,impar[j] + der[j] + t);
    }
    cout << res << endl;
    return 0;
}


#include <iostream>

using namespace std;
#define maxn 100009
typedef long long ll;

int n;

ll izq[maxn],der[maxn],impar[maxn];
ll num[maxn];

ll maxpar(ll value)
{
    return value - value % 2;
}

ll maximpar(ll value)
{
    if(value % 2)return value;
    else
        return value - 1;
}

ll suma(int i, int j)
{
    return impar[j] - impar[i];
}

int main()
{
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        cin >> num[i];
    }

    for(int i = 2; i <= n; i++)
    {
        izq[i] = izq[i - 1] + maxpar(num[i - 1]);
        if(num[i - 1] == 1)izq[i] = 0;
    }

    for(int i = n - 2; i >= 1; i--)
    {
        der[i] = der[i + 1] + maxpar(num[i]);
        if(num[i] == 1)der[i] = 0;
    }

    for(int i = 2; i <= n; i++)
    {
        impar[i] = impar[i - 1] + maximpar(num[i - 1]);
    }

    ll i = 0;
    ll res = 0;
    for(int j = 1; j <= n; j++)
    {
        i = max(i, izq[j] - impar[j]);
        res = max(res,impar[j] + der[j] + i);
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#define dou double
#define LL long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))
#define RL(a) scanf("%I64d", &(a))
#define RLL(a, b) scanf("%I64d%I64d", &(a), &(b))
#define RLLL(a, b, c) scanf("%I64d%I64d%I64d", &(a), &(b), &(c))
#define PI(r) printf("%d\n", (r))
#define PL(r) printf("%I64d\n", (r))
#define RS(s) scanf("%s", (s))
#define SL(a) strlen(a)
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
// Segment tree
#define LC (x << 1)
#define RC ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LB(x) ((x) & (-(x)))
#pragma warning (disable : 4996)
//#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-8
#define inf 2000000000
#define lim (1ll << 60)
#define Mod 1000000007
#define N 111111

using namespace std;

int n, m, L[N], R[N], sum[N], d[N], a[N];

int main(){
	int i, j, k, x, y, z, ca = 1, re = 0;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios :: sync_with_stdio(false);
	RI(n);
	REPP(i, 1, n - 1) RI(a[i]);
	L[1] = 0;
	REPP(i, 2, n) L[i] = a[i - 1] > 1 ? L[i - 1] + a[i - 1] / 2 * 2: 0;
	R[n] = 0;
	for (i = n - 1; i >= 1; --i) R[i] = a[i] > 1 ? R[i + 1] + a[i] / 2 * 2 : 0;
	REPP(i, 2, n) sum[i] = sum[i - 1] + (a[i - 1] % 2 ? a[i - 1] : a[i - 1] - 1);
	REPP(i, 2, n) d[i] =  max(d[i - 1], L[i] - sum[i]);
	REPP(i, 2, n) re = max(re, sum[i] + R[i] + d[i - 1]);
	PI(re);

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#define dou double
#define LL long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))
#define RL(a) scanf("%I64d", &(a))
#define RLL(a, b) scanf("%I64d%I64d", &(a), &(b))
#define RLLL(a, b, c) scanf("%I64d%I64d%I64d", &(a), &(b), &(c))
#define PI(r) printf("%d\n", (r))
#define PL(r) printf("%I64d\n", (r))
#define RS(s) scanf("%s", (s))
#define SL(a) strlen(a)
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
// Segment tree
#define LC (x << 1)
#define RC ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LB(x) ((x) & (-(x)))
#pragma warning (disable : 4996)
//#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-8
#define inf 2000000000
#define lim (1ll << 60)
#define Mod 1000000007
#define N 111111

using namespace std;

int n, m, L[N], R[N], sum[N], d[N], a[N];

int main(){
	int i, j, k, x, y, z, ca = 1, re = 0;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios :: sync_with_stdio(false);
	RI(n);
	REPP(i, 1, n - 1) RI(a[i]);
	L[1] = 0;
	REPP(i, 2, n) L[i] = a[i - 1] > 1 ? L[i - 1] + a[i - 1] / 2 * 2: 0;
	R[n] = 0;
	for (i = n - 1; i >= 1; --i) R[i] = a[i] > 1 ? R[i + 1] + a[i] / 2 * 2 : 0;
	REPP(i, 2, n) sum[i] = sum[i - 1] + (a[i - 1] % 2 ? a[i - 1] : a[i - 1] - 1);
	REPP(i, 2, n) d[i] =  max(d[i - 1], L[i] - sum[i]);
	REPP(i, 2, n) re = max(re, sum[i] + R[i] + d[i - 1]);
	REPP(i, 1, n) re = max(re, L[i] + R[i]);
	//REPP(i, 1, n) cout << i << ' ' << sum[i] << ' ' << L[i] << ' ' << R[i] << ' ' << d[i] << endl;
	PI(re);

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#define dou double
#define LL long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define RI(a) scanf("%d", &(a))
#define RII(a, b) scanf("%d%d", &(a), &(b))
#define RIII(a, b, c) scanf("%d%d%d", &(a), &(b), &(c))
#define RL(a) scanf("%I64d", &(a))
#define RLL(a, b) scanf("%I64d%I64d", &(a), &(b))
#define RLLL(a, b, c) scanf("%I64d%I64d%I64d", &(a), &(b), &(c))
#define PI(r) printf("%d\n", (r))
#define PL(r) printf("%I64d\n", (r))
#define RS(s) scanf("%s", (s))
#define SL(a) strlen(a)
#define mem(a) memset(a, 0, sizeof(a))
#define memm(a) memset(a, -1, sizeof(a))
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); ++i)
// Segment tree
#define LC (x << 1)
#define RC ((x << 1) | 1)
#define MID ((l + r) >> 1)
#define LB(x) ((x) & (-(x)))
#pragma warning (disable : 4996)
//#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-8
#define inf 2000000000
#define lim (1ll << 60)
#define Mod 1000000007
#define N 111111

using namespace std;

LL n, m, L[N], R[N], sum[N], d[N], a[N];

int main(){
	LL i, j, k, x, y, z, ca = 1, re = 0;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios :: sync_with_stdio(false);
	RL(n);
	REPP(i, 1, n - 1) RL(a[i]);
	L[1] = 0;
	REPP(i, 2, n) L[i] = a[i - 1] > 1 ? L[i - 1] + a[i - 1] / 2 * 2: 0;
	R[n] = 0;
	for (i = n - 1; i >= 1; --i) R[i] = a[i] > 1 ? R[i + 1] + a[i] / 2 * 2 : 0;
	REPP(i, 2, n) sum[i] = sum[i - 1] + (a[i - 1] % 2 ? a[i - 1] : a[i - 1] - 1);
	REPP(i, 2, n) d[i] =  max(d[i - 1], L[i] - sum[i]);
	REPP(i, 2, n) re = max(re, sum[i] + R[i] + d[i - 1]);
	REPP(i, 1, n) re = max(re, L[i] + R[i]);
	//REPP(i, 1, n) cout << i << ' ' << sum[i] << ' ' << L[i] << ' ' << R[i] << ' ' << d[i] << endl;
	PL(re);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MOD=7+(int)1e9;
#define N 100005
int n,m,a[N],f[105][N];
long long modpow(long long x,int y){
	long long res=1;
	for(;y;y>>=1,(x*=x)%=MOD)
		if(y&1)(res*=x)%=MOD;
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&f[0][i]);
	while(m--){
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		k++;
		f[k][l]++;//f[k][r+1]--;
		long long tmp=1,wtf=r-l+1;
		for(int i=k;i>=1;i--){
			(f[i][r+1]-=tmp)%=MOD;
			(tmp*=wtf)%=MOD;
			(tmp*=modpow(wtf-(r-l),MOD-2))%=MOD;
			wtf++;
		}
	}for(int x=101;x>=1;x--){
		for(int i=1;i<=n;i++)(f[x][i]+=f[x][i-1])%=MOD;
		for(int i=1;i<=n;i++)(f[x-1][i]+=f[x][i])%=MOD;
	}for(int i=1;i<=n;i++){
		if(i>1)putchar(' ');
		printf("%d",(f[0][i]+MOD)%MOD);
	}
	puts("");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MOD=7+(int)1e9;
#define N 100005
int n,m,a[N],f[105][N],inv[105];
long long modpow(long long x,int y){
	long long res=1;
	for(;y;y>>=1,(x*=x)%=MOD)
		if(y&1)(res*=x)%=MOD;
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=105;i++)inv[i]=modpow(i,MOD-2);
	for(int i=1;i<=n;i++)scanf("%d",&f[0][i]);
	while(m--){
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		k++;
		f[k][l]++;//f[k][r+1]--;
		long long tmp=1,wtf=r-l+1;
		for(int i=k;i>=1;i--){
			(f[i][r+1]-=tmp)%=MOD;
			(tmp*=wtf)%=MOD;
			(tmp*=inv[wtf-(r-l)])%=MOD;
			wtf++;
		}
	}for(int x=101;x>=1;x--){
		for(int i=1;i<=n;i++)(f[x][i]+=f[x][i-1])%=MOD;
		for(int i=1;i<=n;i++)(f[x-1][i]+=f[x][i])%=MOD;
	}for(int i=1;i<=n;i++){
		if(i>1)putchar(' ');
		printf("%d",(f[0][i]+MOD)%MOD);
	}
	puts("");
}


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

const int N = 101010;
const int MOD = 1000000007;

int n, Q;
int a[N];
int delta[111][N];
int C[N][111];

void get_C() {
	for (int i = 0; i < N; ++i) {
		C[i][0] = 1;
		if (i <= 100) C[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			if (j > 100) break;
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}
}

int main() {
	get_C();
	cin >> n >> Q;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		a[i] %= MOD;
	}
	memset(delta, 0, sizeof(delta));
	int l, r, k;
	while (Q--) {
		scanf("%d %d %d", &l, &r, &k);
		++delta[k][l];
		for (int i = 0; i <= k; ++i) {
			delta[i][r + 1] -= C[r - l + k - i][k - i];
			delta[i][r + 1] %= MOD;
			delta[i][r + 1] += MOD;
			delta[i][r + 1] %= MOD;
		}
	}
	for (int i = 100; i >= 0; --i) {
		delta[i][0] = 0;
		for (int j = 1; j <= n; ++j) {
			delta[i][j] =((delta[i][j] + delta[i][j - 1]) % MOD + delta[i + 1][j]) % MOD;
		}
	}
	for (int i = 1; i <= n; ++i) {
		a[i] = (a[i] + delta[0][i]) % MOD;
		printf("%d ", a[i]);
	}
	return 0;
}


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

const int N = 101010;
const int MOD = 1000000007;

int n, Q;
int a[N];
int delta[111][N];
int C[N][111];

void get_C() {
	for (int i = 0; i < N; ++i) {
		C[i][0] = 1;
		if (i <= 100) C[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			if (j > 100) break;
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}
}

int main() {
	get_C();
	cin >> n >> Q;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	memset(delta, 0, sizeof(delta));
	int l, r, k;
	while (Q--) {
		scanf("%d %d %d", &l, &r, &k);
		++delta[k][l];
		for (int i = 0; i <= k; ++i) {
			delta[i][r + 1] -= C[r - l + k - i][k - i];
			delta[i][r + 1] %= MOD;
			delta[i][r + 1] += MOD;
			delta[i][r + 1] %= MOD;
		}
	}
	for (int i = 99; i >= 0; --i) {
		delta[i][0] = 0;
		for (int j = 1; j <= n; ++j) {
			delta[i][j] =((delta[i][j] + delta[i][j - 1]) % MOD + delta[i + 1][j]) % MOD;
		}
	}
/*for (int i = 0; i <= 5; ++i) {
	for (int j = 1; j <= 10; ++j) printf("%d ", delta[i][j]);
	puts("");
}*/
	for (int i = 1; i <= n; ++i) {
		a[i] = (a[i] + delta[0][i]) % MOD;
		printf("%d ", a[i]);
	}
	return 0;
}


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

const int N = 101010;
const int MOD = 1000000007;

int n, Q;
int a[N];
int delta[111][N];
int C[N][111];

void get_C() {
	for (int i = 0; i < N; ++i) {
		C[i][0] = 1;
		if (i <= 100) C[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			if (j > 100) break;
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}
}

int main() {
	get_C();
	cin >> n >> Q;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		a[i] %= MOD;
	}
	memset(delta, 0, sizeof(delta));
	int l, r, k;
	while (Q--) {
		scanf("%d %d %d", &l, &r, &k);
		++delta[k][l];
		for (int i = 0; i <= k; ++i) {
			delta[i][r + 1] -= C[r - l + k - i][k - i];
			delta[i][r + 1] %= MOD;
			delta[i][r + 1] += MOD;
			delta[i][r + 1] %= MOD;
		}
	}
	for (int i = 99; i >= 0; --i) {
		delta[i][0] = 0;
		for (int j = 1; j <= n; ++j) {
			delta[i][j] =((delta[i][j] + delta[i][j - 1]) % MOD + delta[i + 1][j]) % MOD;
		}
	}
	for (int i = 1; i <= n; ++i) {
		a[i] = (a[i] + delta[0][i]) % MOD;
		printf("%d ", a[i]);
	}
	return 0;
}


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

const int N = 100010;
const int MOD = 1000000007;

int n, m, a[N], c[N][105], f[N][105];

int main() {
    // freopen("input.txt", "r", stdin);

    for (int i = 0; i < N; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i && j < 101; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int l, r, k;
    memset(f, 0, sizeof(f));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &l, &r, &k);
        l--;
        int len = (r - l);
        for (int j = 0; j <= k; j++) {
            f[l][j] = (f[l][j] + c[k][k - j]) % MOD;
            f[r][j] = (f[r][j] + MOD - c[k + len][k - j]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            f[i + 1][j] = (f[i + 1][j] + f[i][j] + f[i][j + 1]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        a[i] = (a[i] + f[i][0]) % MOD;
        printf("%d ", a[i]);
    }
    printf("\n");

    return 0;
}


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

const int N = 100010;
const int MOD = 1000000007;

int n, m, a[N], c[N][105], f[N][105];

int main() {
    // freopen("input.txt", "r", stdin);

    for (int i = 0; i < N; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < 101; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int l, r, k;
    memset(f, 0, sizeof(f));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &l, &r, &k);
        l--;
        int len = (r - l);
        for (int j = 0; j <= k; j++) {
            f[l][j] = (f[l][j] + c[k][k - j]) % MOD;
            f[r][j] = ((f[r][j] - c[k + len][k - j]) % MOD + MOD) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 101; j++) {
            f[i + 1][j] = (f[i + 1][j] + f[i][j] + f[i][j + 1]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        a[i] = (a[i] + f[i][0]) % MOD;
        printf("%d ", a[i]);
    }
    printf("\n");

    return 0;
}


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

const int N = 100010;
const int MOD = 1000000007;

int n, m;
long long a[N], c[N][105], f[N][105];

int main() {
    // freopen("input.txt", "r", stdin);

    for (int i = 0; i < N; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < 101; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%I64d", &a[i]);
    }

    int l, r, k;
    memset(f, 0, sizeof(f));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &l, &r, &k);
        l--;
        int len = (r - l);
        for (int j = 0; j <= k; j++) {
            f[l][j] = (f[l][j] + c[k][k - j]) % MOD;
            f[r][j] = ((f[r][j] - c[k + len][k - j]) % MOD + MOD) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 101; j++) {
            f[i + 1][j] = (f[i + 1][j] + f[i][j] + f[i][j + 1]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        a[i] = (a[i] + f[i][0]) % MOD;
        printf("%I64d ", a[i]);
    }
    printf("\n");

    return 0;
}


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

const int N = 100010;
const int MOD = 1000000007;

int n, m, a[N], c[N][105], f[N][105];

int main() {
    // freopen("input.txt", "r", stdin);

    for (int i = 0; i < N; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < 101; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int l, r, k;
    memset(f, 0, sizeof(f));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &l, &r, &k);
        l--;
        int len = (r - l);
        for (int j = 0; j <= k; j++) {
            f[l][j] = (f[l][j] + c[k][k - j]) % MOD;
            f[r][j] = (f[r][j] + MOD - c[k + len][k - j]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 101; j++) {
            f[i + 1][j] = (f[i + 1][j] + f[i][j] + f[i][j + 1]) % MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        a[i] = (a[i] + f[i][0]) % MOD;
        printf("%d ", a[i]);
    }
    printf("\n");

    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007LL
int64 a[MAX_N];
int64 b[MAX_K][MAX_N];
int64 C[MAX_N][MAX_K];
void init(){
    for (int i = 0; i < MAX_N; i++)
        C[i][0] = 1LL;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j <= i && j < MAX_K; j++)
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        b[k][l] += 1LL;
        for (int i = 0; i <= k; i++)
            b[i][r + 1] = (b[i][r + 1] - C[r - l + k - i][k - i]) % MOD;
    }
    for (int i = MAX_K - 2; i >= 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n; j++){
            b[i][j] = (b[i][j] + b[i + 1][j] + b[i][j - 1]) % MOD;
            //printf("%I64d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++)
        a[j] = ((a[j] + b[0][j]) % MOD + MOD) % MOD;
    for (int i = 1; i <= n; i++)
        printf("%I64d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007LL
int64 a[MAX_N];
int64 b[MAX_N][MAX_K];
int64 C[MAX_N][MAX_K];
void init(){
    for (int i = 0; i < MAX_K; i++)
        C[i][0] = 1LL;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j <= i && j < MAX_K; j++)
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        b[k][l] += 1LL;
        for (int i = 0; i <= k; i++)
            b[i][r + 1] = ((b[i][r + 1] - C[r - l + k - i][k - i])) % MOD;
    }
    for (int i = MAX_K - 2; i >= 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n + 1; j++){
            b[i][j] = (b[i][j] + b[i + 1][j] + b[i][j - 1]) % MOD;
            //printf("%I64d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++)
        a[j] = (a[j] + b[0][j]) % MOD;
    for (int i = 1; i <= n; i++)
        printf("%I64d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007LL
int64 a[MAX_N];
int64 b[MAX_K][MAX_N];
int64 C[MAX_N][MAX_K];
void init(){
    for (int i = 0; i < MAX_K; i++)
        C[i][0] = 1LL;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j <= i && j < MAX_K; j++)
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        b[k][l] += 1LL;
        for (int i = 0; i <= k; i++)
            b[i][r + 1] = ((b[i][r + 1] - C[r - l + k - i][k - i])) % MOD;
    }
    for (int i = MAX_K - 2; i >= 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n; j++){
            b[i][j] = (b[i][j] + b[i + 1][j] + b[i][j - 1]) % MOD;
            //printf("%I64d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++)
        a[j] = ((a[j] + b[0][j]) % MOD + MOD) % MOD;
    for (int i = 1; i <= n; i++)
        printf("%I64d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007
int a[MAX_N];
int b[MAX_N][MAX_K];
int C[MAX_N][MAX_K];
inline void MYADD(int &x, int v){
    x += v;
    if (x >= MOD)
        x -= MOD;
}
void init(){
    for (int i = 0; i < MAX_K; i++)
        C[i][0] = 1;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j < MAX_K; j++){
        MYADD(C[i][j], C[i - 1][j]);
        MYADD(C[i][j], C[i - 1][j - 1]);
    }
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        if (k == 0){
            MYADD(b[0][l], 1);
            MYADD(b[0][r + 1], -1);
        }
        else{
            MYADD(b[k + 1][l], 1);
            for (int i = 1; i <= k + 1; i++)
                MYADD(b[i][r + 1], -C[r - l + k + 1 - i][k + 1 - i]);
        }
    }
    for (int j = 1; j <= n+1; j++)
        MYADD(b[0][j], b[0][j - 1]);
    for (int i = MAX_K - 2; i > 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n + 1; j++){
            MYADD(b[i][j], b[i + 1][j]);
            MYADD(b[i][j], b[i][j - 1]);
            //printf("%d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++){
        MYADD(b[0][j], b[1][j]);
        MYADD(a[j], b[0][j]);
    }
    for (int i = 1; i <= n; i++)
        printf("%d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007LL
int64 a[MAX_N];
int64 b[MAX_N][MAX_K];
int64 C[MAX_N][MAX_K];
void init(){
    for (int i = 0; i < MAX_K; i++)
        C[i][0] = 1LL;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j < MAX_K; j++)
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        if (k == 0){
            b[0][l] += 1LL;
            b[0][r + 1] -= 1LL;
        }
        else{
            b[k + 1][l] += 1LL;
            for (int i = 1; i <= k + 1; i++)
                b[i][r + 1] = ((b[i][r + 1] - C[r - l + k + 1 - i][k + 1 - i]) + MOD) % MOD;
        }
    }
    for (int j = 1; j <= n + 1; j++)
        b[0][j] = (b[0][j] + b[0][j - 1]) % MOD;
    for (int i = MAX_K - 2; i > 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n + 1; j++){
            b[i][j] = (b[i][j] + b[i + 1][j] + b[i][j - 1]) % MOD;
            //printf("%I64d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++)
        a[j] = (a[j] + b[0][j] + b[1][j]) % MOD;
    for (int i = 1; i <= n; i++)
        printf("%I64d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 100005
#define MAX_K 105
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007LL
int64 a[MAX_N];
int64 b[MAX_N][MAX_K];
int64 C[MAX_N][MAX_K];
void init(){
    for (int i = 0; i < MAX_K; i++)
        C[i][0] = 1LL;
    for (int i = 1; i < MAX_N; i++) for (int j = 1; j <= i && j < MAX_K; j++)
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    init();
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", a + i);
    while (m--){
        int l, r, k;
        scanf("%d %d %d", &l, &r, &k);
        b[k][l] += 1LL;
        for (int i = 0; i <= k; i++)
            b[i][r + 1] = ((b[i][r + 1] - C[r - l + k - i][k - i])) % MOD;
    }
    for (int i = MAX_K - 2; i >= 0; i--) {
        //printf("K=%d ", i);
        for (int j = 1; j <= n + 1; j++){
            b[i][j] = (b[i][j] + b[i + 1][j] + b[i][j - 1]) % MOD;
            //printf("%I64d ", b[i][j]);
        }
        //puts("");
    }
    for (int j = 1; j <= n; j++)
        a[j] = (((a[j] + b[0][j]) % MOD) + MOD) % MOD;
    for (int i = 1; i <= n; i++)
        printf("%I64d%c", a[i], i == n ? '\n' : ' ');
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#define MAXN 10005
#define mod 1000000007
using namespace std;
int n,m, a[MAXN],c[MAXN * 2][105];
struct query{
    int l, r, k;
}q[MAXN];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)scanf("%d",&a[i]);
    for(int i = 1; i <= m; i ++)scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].k);
    c[1][0] = c[0][0] = c[1][1] = 1;
    for(int i = 2; i <= MAXN * 2 - 3; i ++){
        c[i][0] = c[i][i] = 1;
        for(int j = 1; j < min(i, 102); j ++)c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    /*for(int i = 1; i <= n; i ++){
        for(int j = 0; j<= i ; j ++)printf("%d ", c[i][j]);cout<<endl;  }*/
    for(int i = 1; i <= m; i ++){
        for(int j = q[i].l; j <= q[i].r; j ++)
            a[j] =(a[j] + c[j - q[i].l + q[i].k][q[i].k]) % mod;
    }
    for(int i = 1; i <= n; i ++)printf("%d ", a[i]);cout<<endl;
//  system("pause");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#define MAXN 10005
#define mod 1000000007
using namespace std;
int n,m, a[MAXN],c[MAXN * 2][105];
struct query{
    int l, r, k;
}q[MAXN];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)scanf("%d",&a[i]);
    for(int i = 1; i <= m; i ++)scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].k);
    c[1][0] = c[0][0] = c[1][1] = 1;
    for(int i = 2; i <= MAXN * 2 - 3; i ++){
        c[i][0] = c[i][i] = 1;
        for(int j = 1; j < min(i, 102); j ++)c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    /*for(int i = 1; i <= n; i ++){345678
        for(int j = 0; j<= i ; j ++)printf("%d ", c[i][j]);cout<<endl;  }*/
    for(int i = 1; i <= m; i ++){
        for(int j = q[i].l; j <= q[i].r; j ++)
            a[j] =(a[j] + c[j - q[i].l + q[i].k][q[i].k]) % mod;
    }
    for(int i = 1; i <= n; i ++)printf("%d ", a[i]);cout<<endl;
//  system("pause");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#define MAXN 10005
#define mod 1000000007
using namespace std;
int n,m, a[MAXN],c[MAXN][105];
struct query{
    int l, r, k;
}q[MAXN];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)scanf("%d",&a[i]);
    for(int i = 1; i <= m; i ++)scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].k);
    c[1][0] = c[0][0] = c[1][1] = 1;
    for(int i = 2; i <= MAXN - 5; i ++){
        c[i][0] = c[i][i] = 1;
        for(int j = 1; j < min(i, 102); j ++)c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    /*for(int i = 1; i <= n; i ++){
        for(int j = 0; j<= i ; j ++)printf("%d ", c[i][j]);cout<<endl;  }*/
    for(int i = 1; i <= m; i ++){
        for(int j = q[i].l; j <= q[i].r; j ++)
            a[j] =(a[j] + c[j - q[i].l + q[i].k][q[i].k]) % mod;
    }
    for(int i = 1; i <= n; i ++)printf("%d ", a[i]);cout<<endl;
//  system("pause");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#define MAXN 10005
#define mod 1000000007
using namespace std;
int n,m, a[MAXN],c[MAXN][105];
struct query{
    int l, r, k;
}q[MAXN];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)scanf("%d",&a[i]);
    for(int i = 1; i <= m; i ++)scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].k);
    c[1][0] = c[0][0] = c[1][1] = 1;
    for(int i = 2; i <= n; i ++){
        c[i][0] = c[i][i] = 1;
        for(int j = 1; j < min(i, 102); j ++)c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    for(int i = 1; i <= m; i ++){
        for(int j = q[i].l; j <= q[i].r; j ++)
            a[j] =(a[j] + c[j - q[i].l + q[i].k][q[i].k]) % mod;
    }
    for(int i = 1; i <= n; i ++)printf("%d ", a[i]);cout<<endl;
//  system("pause");
    return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

const int mod = 1000 * 1000 * 1000 + 7;
const int maxn = 1000 * 100 + 10;
const int maxk = 110;

int c[maxn][maxk], a[maxn], l, r, k;

int main() {
//	freopen("in", "r", stdin);
//	freopen("out2", "w", stdout);

	int n, m;

	cin >> n >> m;

	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	for (int i = 0; i <= n; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= min(i, 100); ++j)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}

	for (int i = 1; i <= m; ++i) {
		cin >> l >> r >> k;

		for (int j = l; j <= r; ++j)
			a[j] = (a[j] + c[j - l + k][k]) % mod;
	}

	for (int i = 1; i <= n; ++i)
		cout << a[i] << ' ';

	return 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back

const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 2 * 1000 * 1000 * 1000;
const int maxn = 1000 * 100 + 10;
const int maxk = 100;

int n, m, l, r, k, s[maxk + 10][maxn], p[maxn], a[maxn], c[maxk + 10][maxn];

int main() {
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;

	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	for (int i = 0; i <= n; ++i) {
		c[0][i] = 1;
		for (k = 1; k <= min(maxk, i); ++k)
			c[k][i] = (c[k][i - 1] + c[k - 1][i - 1]) % mod;
	}

	for (int i = 0; i < m; ++i) {
		cin >> l >> r >> k;
		s[maxk - k][l] = (s[maxk - k][l] + 1) % mod;
		for (int j = 0; j <= k; ++j)
			s[maxk - k + j][r + 1] = (s[maxk - k + j][r + 1] + mod - c[j][r - l + j]) % mod;
	}

	for (k = 1; k <= maxk + 1; ++k)
		for (int i = 1; i <= n; ++i) {
			p[i] = (p[i - 1] + s[k - 1][i]) % mod;
			s[k][i] = (s[k][i] + p[i]) % mod;
		}

	for (int i = 1; i <= n; ++i)
		cout << (s[maxk + 1][i] + a[i]) % mod << ' ';

	return 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back

const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 2 * 1000 * 1000 * 1000;
const int maxn = 2000 * 100 + 10;
const int maxk = 100;

int n, m, l, r, k, s[maxk + 10][maxn], p[maxn], a[maxn], c[maxk + 10][maxn];

int main() {
//	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;

	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	for (int i = 0; i <= n + 1000; ++i) {
		c[0][i] = 1;
		for (k = 1; k <= min(maxk, i); ++k)
			c[k][i] = (c[k][i - 1] + c[k - 1][i - 1]) % mod;
	}

	for (int i = 0; i < m; ++i) {
		cin >> l >> r >> k;
		s[maxk - k][l] = (s[maxk - k][l] + 1) % mod;
		for (int j = 0; j <= k; ++j)
			s[maxk - k + j][r + 1] = (s[maxk - k + j][r + 1] + mod - c[j][r - l + j]) % mod;
	}

	for (k = 1; k <= maxk + 1; ++k)
		for (int i = 1; i <= n; ++i) {
			p[i] = (p[i - 1] + s[k - 1][i]) % mod;
			s[k][i] = (s[k][i] + p[i]) % mod;
		}

	for (int i = 1; i <= n; ++i)
		cout << (s[maxk + 1][i] + a[i]) % mod << ' ';

	return 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back

const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 2 * 1000 * 1000 * 1000;
const int maxn = 1000 * 100 + 10;
const int maxk = 100;

int n, m, l, r, k, s[maxk + 10][maxn], p[maxn], a[maxn], c[maxk + 10][maxn];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;

	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	for (int i = 0; i <= n; ++i) {
		c[0][i] = 1;
		for (k = 1; k <= min(maxk, i); ++k)
			c[k][i] = (c[k][i - 1] + c[k - 1][i - 1]) % mod;
	}

	for (int i = 0; i < m; ++i) {
		cin >> l >> r >> k;
		s[maxk - k][l] = (s[maxk - k][l] + 1) % mod;
		for (int j = 0; j <= k; ++j)
			s[maxk - k + j][r + 1] = (s[maxk - k + j][r + 1] + mod - c[j][r - l + 1]) % mod;
	}

	for (k = 1; k <= maxk + 1; ++k)
		for (int i = 1; i <= n; ++i) {
			p[i] = (p[i - 1] + s[k - 1][i]) % mod;
			s[k][i] = (s[k][i] + p[i]) % mod;
		}

	for (int i = 1; i <= n; ++i)
		cout << (s[maxk + 1][i] + a[i]) % mod << ' ';

	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
       int L, R;
};
const int P = 1000000007;
int step, C[200001][101], n, m, pos1[100001], pos2[100001];
long long f[100001][101], a[100001];
vector<node> v[101];

bool cmp1(const int &x, const int &y){
    return v[step][x].L < v[step][y].L;
}

bool cmp2(const int &x, const int &y){
    return v[step][x].R < v[step][y].R;
}

int main(){
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    C[0][0] = 1;
    for (int i = 1; i <= 200000; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= min(i, 100); j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
            C[i][j] %= P;
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    for (int i = 0; i <= 100; i++) v[i].clear();
    for (int i = 1; i <= m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        node now;
        now.L = x; now.R = y;
        v[z].push_back(now);
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= i; j++) f[1][j] = 0;
        int cnt = v[i].size();
        for (int j = 0; j < cnt; j++) pos1[j] = j, pos2[j] = j;
        step = i;
        sort(pos1, pos1 + cnt, cmp1);
        sort(pos2, pos2 + cnt, cmp2);
        int Left1 = 0, Left2 = 0;
        for (int j = 1; j <= n; j++)
        {
            for (;Left1 < cnt && v[i][pos1[Left1]].L == j; ++Left1)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] += C[i][k], f[j][k] %= P;
            }
            a[j] += f[j][i]; a[i] %= P;
            for (;Left2 < cnt && v[i][pos2[Left2]].R == j; ++Left2)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] -= C[v[i][pos2[Left2]].R - v[i][pos2[Left2]].L + i][k],
                    f[j][k] += P, f[j][k] %= P;
            }
            if (j != n)
            {
               f[j + 1][0] = f[j][0];
               for (int k = 1; k <= i; k++) f[j + 1][k] = f[j][k] + f[j][k - 1],
                                            f[j + 1][k] %= P;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d", a[i]);
        if (i != n) printf(" ");
        else printf("\n");
    }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
       int L, R;
};
const int P = 1000000007;
int step, C[100001][101], a[100001], n, m, pos1[100001], pos2[100001], f[100001][101];
vector<node> v[101];

bool cmp1(const int &x, const int &y){
    return v[step][x].L < v[step][y].L;
}

bool cmp2(const int &x, const int &y){
    return v[step][x].R < v[step][y].R;
}

int main(){
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    C[0][0] = 1;
    for (int i = 1; i <= 100000; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= min(i, 100); j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
            C[i][j] %= P;
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i <= 100; i++) v[i].clear();
    for (int i = 1; i <= m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        node now;
        now.L = x; now.R = y;
        v[z].push_back(now);
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= i; j++) f[1][j] = 0;
        int cnt = v[i].size();
        for (int j = 0; j < cnt; j++) pos1[j] = j, pos2[j] = j;
        step = i;
        sort(pos1, pos1 + cnt, cmp1);
        sort(pos2, pos2 + cnt, cmp2);
        int Left1 = 0, Left2 = 0;
        for (int j = 1; j <= n; j++)
        {
            for (;Left1 < cnt && v[i][pos1[Left1]].L == j; ++Left1)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] += C[i][k], f[j][k] %= P;
            }
            a[j] += f[j][i]; a[i] %= P;
            for (;Left2 < cnt && v[i][pos2[Left2]].R == j; ++Left2)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] -= C[v[i][pos2[Left2]].R - v[i][pos2[Left2]].L + i][k],
                    f[j][k] += P, f[j][k] %= P;
            }
            if (j != n)
            {
               f[j + 1][0] = f[j][0];
               for (int k = 1; k <= i; k++) f[j + 1][k] = f[j][k] + f[j][k - 1],
                                            f[j + 1][k] %= P;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d", a[i]);
        if (i != n) printf(" ");
        else printf("\n");
    }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
       int L, R;
};
const int P = 1000000007;
int step, C[200001][101], n, m, pos1[100001], pos2[100001];
long long f[100001][101], a[100001]；
vector<node> v[101];

bool cmp1(const int &x, const int &y){
    return v[step][x].L < v[step][y].L;
}

bool cmp2(const int &x, const int &y){
    return v[step][x].R < v[step][y].R;
}

int main(){
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    C[0][0] = 1;
    for (int i = 1; i <= 200000; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= min(i, 100); j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
            C[i][j] %= P;
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    for (int i = 0; i <= 100; i++) v[i].clear();
    for (int i = 1; i <= m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        node now;
        now.L = x; now.R = y;
        v[z].push_back(now);
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= i; j++) f[1][j] = 0;
        int cnt = v[i].size();
        for (int j = 0; j < cnt; j++) pos1[j] = j, pos2[j] = j;
        step = i;
        sort(pos1, pos1 + cnt, cmp1);
        sort(pos2, pos2 + cnt, cmp2);
        int Left1 = 0, Left2 = 0;
        for (int j = 1; j <= n; j++)
        {
            for (;Left1 < cnt && v[i][pos1[Left1]].L == j; ++Left1)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] += C[i][k], f[j][k] %= P;
            }
            a[j] += f[j][i]; a[i] %= P;
            for (;Left2 < cnt && v[i][pos2[Left2]].R == j; ++Left2)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] -= C[v[i][pos2[Left2]].R - v[i][pos2[Left2]].L + i][k],
                    f[j][k] += P, f[j][k] %= P;
            }
            if (j != n)
            {
               f[j + 1][0] = f[j][0];
               for (int k = 1; k <= i; k++) f[j + 1][k] = f[j][k] + f[j][k - 1],
                                            f[j + 1][k] %= P;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d", a[i]);
        if (i != n) printf(" ");
        else printf("\n");
    }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
       int L, R;
};
const int P = 1000000007;
int step, C[200001][101], a[100001], n, m, pos1[100001], pos2[100001], f[100001][101];
vector<node> v[101];

bool cmp1(const int &x, const int &y){
    return v[step][x].L < v[step][y].L;
}

bool cmp2(const int &x, const int &y){
    return v[step][x].R < v[step][y].R;
}

int main(){
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    C[0][0] = 1;
    for (int i = 1; i <= 200000; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= min(i, 100); j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
            C[i][j] %= P;
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i <= 100; i++) v[i].clear();
    for (int i = 1; i <= m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        node now;
        now.L = x; now.R = y;
        v[z].push_back(now);
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= i; j++) f[1][j] = 0;
        int cnt = v[i].size();
        for (int j = 0; j < cnt; j++) pos1[j] = j, pos2[j] = j;
        step = i;
        sort(pos1, pos1 + cnt, cmp1);
        sort(pos2, pos2 + cnt, cmp2);
        int Left1 = 0, Left2 = 0;
        for (int j = 1; j <= n; j++)
        {
            for (;Left1 < cnt && v[i][pos1[Left1]].L == j; ++Left1)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] += C[i][k], f[j][k] %= P;
            }
            a[j] += f[j][i]; a[i] %= P;
            for (;Left2 < cnt && v[i][pos2[Left2]].R == j; ++Left2)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] -= C[v[i][pos2[Left2]].R - v[i][pos2[Left2]].L + i][k],
                    f[j][k] += P, f[j][k] %= P;
            }
            if (j != n)
            {
               f[j + 1][0] = f[j][0];
               for (int k = 1; k <= i; k++) f[j + 1][k] = f[j][k] + f[j][k - 1],
                                            f[j + 1][k] %= P;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d", a[i]);
        if (i != n) printf(" ");
        else printf("\n");
    }
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
       int L, R;
};
const int P = 1000000007;
int step, C[200001][101], a[100001], n, m, pos1[100001], pos2[100001], f[100001][101];
vector<node> v[101];

bool cmp1(const int &x, const int &y){
    return v[step][x].L < v[step][y].L;
}

bool cmp2(const int &x, const int &y){
    return v[step][x].R < v[step][y].R;
}

int main(){
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    C[0][0] = 1;
    for (int i = 1; i <= 200000; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= min(i, 100); j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
            C[i][j] %= P;
    }
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i <= 100; i++) v[i].clear();
    for (int i = 1; i <= m; i++)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        node now;
        now.L = x; now.R = y;
        v[z].push_back(now);
    }
    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= i; j++) f[1][j] = 0;
        int cnt = v[i].size();
        for (int j = 0; j < cnt; j++) pos1[j] = j, pos2[j] = j;
        step = i;
        sort(pos1, pos1 + cnt, cmp1);
        sort(pos2, pos2 + cnt, cmp2);
        int Left1 = 0, Left2 = 0;
        for (int j = 1; j <= n; j++)
        {
            for (;Left1 < cnt && v[i][pos1[Left1]].L == j; ++Left1)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] += C[i][k], f[j][k] %= P;
            }
            a[j] += f[j][i]; a[j] %= P;
            for (;Left2 < cnt && v[i][pos2[Left2]].R == j; ++Left2)
            {
                for (int k = 0; k <= i; k++)
                    f[j][k] -= C[v[i][pos2[Left2]].R - v[i][pos2[Left2]].L + i][k],
                    f[j][k] += P, f[j][k] %= P;
            }
            if (j != n)
            {
               f[j + 1][0] = f[j][0];
               for (int k = 1; k <= i; k++) f[j + 1][k] = f[j][k] + f[j][k - 1],
                                            f[j + 1][k] %= P;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d", a[i]);
        if (i != n) printf(" ");
        else printf("\n");
    }
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		sum[i] = (sum[i] + type*co[l][k - i])%MOD;
	}
}
int main() {
	// freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			co[i][j] = (co[i - 1][j - 1] + co[i - 1][j])%MOD;
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(0, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, -k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(k >= 0)
					sum[k] = (sum[k] + 1)%MOD;
				else
					change(-k, i - pa[l].SE.FI - k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	arr[i] = (arr[i] + sum[j])%MOD;
			for(int j = MAXM - 2; j >= 0 ; --j) sum[j] = (sum[j] + sum[j + 1])%MOD;
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

inline void add(int &a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	else if(a <= - MOD) a += MOD;
}
inline void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		add(sum[i], type*co[l - i][k - i]);
	}
}
int main() {
	//freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			add(co[i][j], co[i - 1][j - 1] + co[i - 1][j]);
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(-1, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(pa[l].SE.FI < 0)
					add(sum[k], 1);
				else
					change(k, i - pa[l].SE.FI + k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	add(arr[i], sum[j]);
			for(int j = MAXM - 2; j >= 0 ; --j) add(sum[j], sum[j + 1]);
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		sum[i] = (sum[i] + type*co[l - i][k - i])%MOD;
	}
}
int main() {
	//freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			co[i][j] = (co[i - 1][j - 1] + co[i - 1][j])%MOD;
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(-1, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(pa[l].SE.FI < 0)
					sum[k] = (sum[k] + 1)%MOD;
				else
					change(k, i - pa[l].SE.FI + k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	arr[i] = (arr[i] + sum[j])%MOD;
			for(int j = MAXM - 2; j >= 0 ; --j) sum[j] = (sum[j] + sum[j + 1])%MOD;
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

void add(int &a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	else if(a <= - MOD) a += MOD;
}
void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		add(sum[i], type*co[l - i][k - i]);
	}
}
int main() {
	//freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			add(co[i][j], co[i - 1][j - 1] + co[i - 1][j]);
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(-1, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(pa[l].SE.FI < 0)
					add(sum[k], 1);
				else
					change(k, i - pa[l].SE.FI + k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	add(arr[i], sum[j]);
			for(int j = MAXM - 2; j >= 0 ; --j) add(sum[j], sum[j + 1]);
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

void add(int &a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
}
void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		add(sum[i], type*co[l - i][k - i]);
	}
}
int main() {
	//freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			co[i][j] = (co[i - 1][j - 1] + co[i - 1][j])%MOD;
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(-1, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(pa[l].SE.FI < 0)
					add(sum[k], 1);
				else
					change(k, i - pa[l].SE.FI + k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	add(arr[i], sum[j]);
			for(int j = MAXM - 2; j >= 0 ; --j) add(sum[j], sum[j + 1]);
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <time.h>
#include <vector>
#include <set>
#define MP(x, y) make_pair(x, y)
#define FI first
#define SE second
using namespace std;
const int MAXN = 100010;
const int MAXM = 110;
const int MOD = 1000000007;

pair<int, pair<int, int> > pa[MAXN*2];
int sum[MAXM], arr[MAXN];
int co[MAXN][MAXM];

void add(int &a, int b) {
	a += b;
	if(a >= MOD) a -= MOD;
	else if(a <= - MOD) a += MOD;
}
void change(int k, int l, int type) {
	--l;
	for(int i = 0; i <= k; ++i) {
		add(sum[i], type*co[l - i][k - i]);
	}
}
int main() {
	//freopen("/home/caesar11/Code/input", "r", stdin);
	int n, m;
	co[0][0] = 1;
	for(int i = 1; i < MAXN; ++i) {
		co[i][0] = 1;
		for(int j = 1; j < MAXM; ++j)
			co[i][j] = (co[i - 1][j - 1] + co[i - 1][j])%MOD;
	}
	while(scanf("%d%d", &n, &m) == 2) {
		for(int i = 0; i < n; ++i)
			scanf("%d", &arr[i]);
		for(int i = 0; i < m; ++i)
		{
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			pa[i*2] = MP(l - 1, MP(-1, k));
			pa[i*2 + 1] = MP(r, MP(l - 1, k));
		}
		sort(pa, pa + 2*m);
		memset(sum, 0, sizeof(sum));
		for(int i = 0, l = 0; i < n; ++i) {
			while(l < 2*m && i == pa[l].FI) {
				int k = pa[l].SE.SE;
				if(pa[l].SE.FI < 0)
					add(sum[k], 1);
				else
					change(k, i - pa[l].SE.FI + k, -1);
				++l;
			}
			for(int j = 0; j < MAXM; ++j)	add(arr[i], sum[j]);
			for(int j = MAXM - 2; j >= 0 ; --j) add(sum[j], sum[j + 1]);
		}
		for(int i = 0; i < n; ++i)
			printf("%d%s", (arr[i] + MOD)%MOD, i < n - 1 ? " ": "");
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 31011
#define EPS 1000000007
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][101];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);
    for(int i=0;i<=n;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i&&j<=MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(int l,int r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i])%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r+1-l][k-i])%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(int i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 100.0000000
#define SIGMA_SIZE 4
#define MOD 31011
#define EPS 1e-13
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

int n,m,a[MAX],ans[MAX][110],C[MAX][101];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);
    for(int i=0;i<=n;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i&&j<=MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(int l,int r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i])%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r+1-l][k-i])%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(int i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 100.0000000
#define SIGMA_SIZE 4
#define MOD 31011
#define EPS 1e-13
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][101];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);
    for(int i=0;i<=n;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i&&j<=MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(int l,int r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i])%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r+1-l][k-i])%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(int i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 1010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 1000000007
#define EPS 1e-12
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);C[0][0]=1;
    for(int i=1;i<=MAX;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i&&j<MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i]+MOD)%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r-l+1][k-i]+MOD)%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 31011
#define EPS 1000000007
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);
    for(int i=0;i<=n;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i&&j<=MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i])%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r+1-l][k-i])%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 1000000007
#define EPS 1e-12
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);C[0][0]=1;
    for(int i=1;i<=MAX;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i&&j<MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i]+MOD)%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r-l+1][k-i]+MOD)%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<=n;++i)
        for(int j=101;j>=1;--j)
            ans[i][j-1]=(ans[i][j-1]+ans[i-1][j]+ans[i-1][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 1000000007
#define EPS 1e-12
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(C);C[0][0]=1;
    for(int i=1;i<=MAX;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i&&j<MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i]+MOD)%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r-l+1][k-i]+MOD)%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    CLEAR(ans);
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<=n;++i)
        for(int j=101;j>=1;--j)
            ans[i][j-1]=(ans[i][j-1]+ans[i-1][j]+ans[i-1][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 1000000007
#define EPS 1e-12
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);
    for(int i=0;i<=n;i++)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i&&j<=MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i])%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r+1-l][k-i])%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#define MAX 100010
#define MAXM 101
#define INF 1000000000
#define SIGMA_SIZE 4
#define MOD 1000000007
#define EPS 1e-12
#define CLEAR(x) memset(x,0,sizeof(x));

using namespace std;

long long n,m,a[MAX],ans[MAX][110],C[MAX][110];
void Combo()
{
    CLEAR(ans);
    CLEAR(C);C[0][0]=1;
    for(int i=1;i<=MAX;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i&&j<MAXM;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
    }
}
void ins(long long l,long long r,int k)
{
    for(int i=0;i<=k;i++) ans[l][i]=(ans[l][i]+C[k][k-i]+MOD)%MOD;
    for(int i=0;i<=k;i++) ans[r+1][i]=(ans[r+1][i]-C[k+r-l+1][k-i]+MOD)%MOD;
}
int main()
{
#ifdef LOCAL
    freopen("/Users/tegusi/Documents/NOI/bin/Debug/in.txt","r",stdin);
#endif
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    Combo();
    for(long long i=1,l,r,k;i<=m;i++)
    {
        cin>>l>>r>>k;ins(l, r, k);
    }
//    for(int i=2;i<=n;i++)
//        for(int j=101;j>=1;j--)
//            ans[i][j]=(ans[i][j]+ans[i-1][j+1]+ans[i-1][j])%MOD;
    for(int i=1;i<n;++i)
        for(int j=101;j>=1;--j)
            ans[i+1][j-1]=(ans[i+1][j-1]+ans[i][j]+ans[i][j-1])%MOD;
    for(int i=1;i<=n;++i)
        cout<<((ans[i][0]+a[i])%MOD+MOD)%MOD<<" ";
    printf("\n");

}


#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
const int mod = 1000000007;
int comb[100200][110];
int ev[110][100200];
int a[100200];
inline int add(int x, int y) {
	if (x + y >= mod) return x + y - mod;
	if (x + y < 0) return x + y + mod;
	return x + y;
}
int main() {
	int n, m;
	comb[0][0] = 1;
	for (int i = 1; i < 100200; i++) {
		comb[i][0] = 1;
		for (int j = 1; j < 110; j++) {
			comb[i][j] = add(comb[i-1][j-1], comb[i-1][j]);
		}
	}
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	while (m--) {
		int l, r, k;
		scanf("%d%d%d", &l, &r, &k);
		--l;
		ev[k][l] = add(ev[k][l], 1);
		for (int i = 0; i <= k; i++) {
			ev[k-i][r] = add(ev[k-i][r], mod-comb[r-l-1+i][i]);
		}
	}
	for (int i = 100; i >= 0; i--) {
		for (int j = 0; j <= n; j++) {
			if (j) {
				ev[i][j] = add(ev[i][j], ev[i][j-1]);
			}
			ev[i][j] = add(ev[i][j], ev[i+1][j]);
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d%c", add(a[i], ev[0][i]), i==n-1 ? '\n' : ' ');
	}
	return 0;
}