#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<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100009][2];
vector<ll>vec;
ll M;
ll n;
ll call(ll pos,ll pev)
{
    if(pos==0)
    {
        return 1;
    }
    if(dp[pos][pev]!=-1)
    {
        return dp[pos][pev];
    }
    ll x,y;
    if(pev==0)
    {
        x=call(pos-1,0);
        y=call(pos-1,1);
        x=(x+y)%M;
    }
    else
    {
        x=call(pos-1,0);
        x=x%M;
    }

    return dp[pos][pev]=x;
}
int main()
{
    ll a,b,c,d,e,i,j,k,l,m,x,y,t,p;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        vec.push_back(a);
    }
    m=M=(1e9)+7;
    memset(dp,-1,sizeof(dp));
    for(i=n;i>=0;i--)
    {
        x=call(i,0);
        x=call(i,1);
    }
    dp[0][0]=dp[0][1]=1;
    if(n==1)
    {
        cout<<vec[0]<<endl;
        return 0;
    }
    if(n==2)
    {
        x=(vec[0]*2);
        cout<<x<<endl;
        return 0;
    }
    ll ans=0;
    x=(dp[n-1][0]*vec[0])%M;
    ans=x;
    //cout<<ans<<endl;
    x=(dp[n-2][0]*vec[1])%M;
    ans=(ans+x)%M;
    x=(dp[n-2][1]*vec[1])%M;
    ans=(ans-x)%m;
    ans=(ans+M)%M;
    //cout<<ans<<endl;
    for(i=2;i<n;i++)
    {
        a=dp[i-1][0];
        b=dp[(n-1)-i][0];
        //cout<<a<<" "<<b<<endl;
        b=(a*b)%M;
        b=(b*vec[i])%M;
        a=dp[i-1][1];
        c=dp[(n-1)-i][1];
        //cout<<a<<"  "<<c<<endl;
        c=(c*a)%M;
        c=(c*vec[i])%M;
        b=(b-c)%M;
        b=(b+M)%M;
        ans=(ans+b)%M;
    }

    cout<<ans<<endl;
}
