#include <bits/stdc++.h>

#define eprintf(args...) fprintf(stderr, args)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 1e5 + 5;
const int mod = 1e9 + 7;
int f[mxn];
int n, a[mxn];

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	f[0] = 1; f[1] = 2;
	for (int i = 1; i < n; ++ i) f[i + 1] = (f[i - 1] + f[i]) % mod;
	int ans = 0;
	rep(i, n) {
		int coef = 1LL * (i ? f[i - 1] : 1) * f[n - 1 - i] % mod;
		if (i) coef = (coef + mod - 1LL * (i - 1 ? f[i - 2] : 1) * (n - 1 - i ? f[n - 2 - i] : 1) % mod) % mod;
		(ans += 1LL * coef * a[i] % mod) %= mod;
	}
	printf("%d\n", ans);
	return 0;
}

#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=1e5+7;
const ll p=1e9+7;
ll read(){
	char c;ll x=0,f=1;
	while(!isdigit(c=getchar()))f-=2*(c=='-');
	while(isdigit(c))x=x*10+f*(c-48),c=getchar();
	return x;
}
ll n,res,x,f[N],g[N],h[N];
int main(){
	n=read(),h[1]=0,h[2]=1,f[1]=read();
	for(ll i=3;i<=n;++i)h[i]=(h[i-1]+h[i-2])%p;
	for(ll i=2;i<=n;++i){
		x=read();
		f[i]=(f[i-1]+x*h[i]+(i>2)*(g[i-1]+x*h[i-1]))%p;
		g[i]=((f[i-1]-x*h[i])%p+p)%p;
	}
	res=(f[n]+g[n])%p;printf("%lld",res);
	return 0;
}