#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()
#define siz(x) (int) x.size()
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define FOR(i, a, b) for(auto i=(a); i<(b); i++)
#define ROF(i, a, b) for(auto i=(b)-1; i>=(a); i--)
#define F0R(i, n) FOR(i, 0, n)
#define R0F(i, n) ROF(i, 0, n)

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll, ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vpii=vector<pii>;

template<class T> bool ckmin(T&a, const T&b) {return b<a?a=b,1:0;}
template<class T> bool ckmax(T&a, const T&b) {return b>a?a=b,1:0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=1e5+10;
const int MOD=1e9+7; 
const ll infLL=1e18;
const ld eps=1e-6;

template<int mod> struct mint {
	int v; explicit operator int() const{return v;} 
	mint() {v=0;}
	mint(ll _v) { v =int((-mod< _v&&_v<mod)?_v:_v%mod);
		if(v < 0) v+=mod;}
	friend bool operator==(const mint& a, const mint& b){ 
		return a.v==b.v;}
	friend bool operator!=(const mint& a, const mint& b){ 
		return !(a==b);}
	friend bool operator<(const mint& a, const mint& b){ 
		return a.v<b.v;}
	mint& operator+=(const mint& m) { 
		if((v+=m.v)>=mod) v-=mod; 
		return *this;}
	mint& operator-=(const mint& m) { 
		if((v-=m.v)<0) v+=mod; 
		return *this;}
	mint& operator*=(const mint& m){ 
		v=int((ll)v*m.v%mod); return *this;}
	mint& operator/=(const mint& m) {return (*this)*=inv(m);}
	friend mint pow(mint a, ll p) {
		mint ans = 1; assert(p >= 0);
		for (;p;p/=2,a*=a) if(p&1) ans*=a;
		return ans;}
	friend mint inv(const mint& a){assert(a.v!=0); 
		return pow(a,mod-2);}
	mint operator-() const{return mint(-v);}
	friend mint operator+(mint a, const mint& b) {return a+=b;}
	friend mint operator-(mint a, const mint& b) {return a-=b;}
	friend mint operator*(mint a, const mint& b) {return a*=b;}
	friend mint operator/(mint a, const mint& b) {return a/=b;}
};

using mi=mint<MOD>;

vector<mi> invs, fac, ifac; 
void genFac(int SZ=mxN) {
	invs.resize(SZ), fac.resize(SZ), ifac.resize(SZ); vi Invs(SZ);
	Invs[1]=1; invs[1]=fac[0]=ifac[0]=1; 
	FOR(i,2,SZ) Invs[i] = int(MOD-(ll)MOD/i*Invs[MOD%i]%MOD), invs[i]=mi(Invs[i]);
	FOR(i,1,SZ) {
		fac[i]=fac[i-1]*i;
		ifac[i]=ifac[i-1]*invs[i];
	}
}

mi choose(int n, int k){
	if(k>n) return 0;
	return fac[n]*ifac[n-k]*ifac[k];
}

int n; 
int a[mxN]; 

mi dp[mxN][2]; 

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n; 
	F0R(i, n) cin >> a[i]; 
	dp[0][0]=1; 
	FOR(i, 1, n+1){
		dp[i][0]=dp[i-1][0]+dp[i-1][1]; 
		dp[i][1]=dp[i-1][0]; 
	}
	mi ans=0;
	F0R(i, n){
		if(i==0){
			ans+=(dp[n-1][0]+dp[n-1][1])*a[i]; 
		}
		else{
			ans+=(dp[n-1-i][0]+dp[n-1-i][1])*(dp[i-1][0]+dp[i-1][1])*a[i]; 
			ans-=dp[n-1-i][0]*dp[i-1][0]*a[i]; 
		}
	}
	cout << ans.v << "\n"; 
	return 0; 
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r)
{
    return uniform_int_distribution<int>(l, r)(rng);
}

void run_case() {
    ll n;
    cin>>n;
    vector<ll> vec(n);
    for(auto& it : vec) cin>>it;

    ll dp[n+100][2];
    memset(dp, 0, sizeof(dp));
    dp[1][0] = 1;
    dp[1][1] = 1;
    for(int i = 2; i <= n+5; ++i) {
        (dp[i][0] = dp[i-1][0] + dp[i-1][1]) %= mod;
        (dp[i][1] = dp[i-1][0]) %= mod;
    }

    dp[0][0] = dp[0][1] = 0;
    dp[0][0] = 1;

    ll sum = (vec[0] * ((dp[n-1][0] + dp[n-1][1])%mod))%mod;
    for(int i = 1; i < n; ++i) {
        ll cur1 = (dp[i-1][0] + dp[i-1][1])%mod;
        (cur1 *= (dp[n - i - 1][0] + dp[n - i - 1][1])) %= mod;
        (sum += cur1 * vec[i]) %= mod;
        
        ll cur2 = (dp[i-1][0])%mod;
        (cur2 *= dp[n-i-1][0]) %= mod;
        (sum -= cur2*vec[i]) %= mod;
        (sum += mod) %= mod;
        //cout<<cur1<<" "<<cur2<<" "<<dp[n-i-1][1]<<" "<<sum<<endl;
    }
    cout<<sum%mod<<endl;
}

int32_t main()  {
    fastio
    int t = 1;
    //cin>>t;
    for(int i = 0; i < t; ++i) {
        run_case();  
    }
}