#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#define ALL(a) (a).begin(), (a).end()
 
const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;
 
int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<ll> F(N + 1);
  F[0] = 1;
  F[1] = 1;
  for (int i = 2; i <= N; i++){
    F[i] = (F[i - 1] + F[i - 2]) % MOD;
  }
  ll ans = 0;
  ans += F[N] * A[0] % MOD;
  for (int i = 1; i < N; i++){
    ans += F[i] * F[N - i] % MOD * A[i] % MOD;
    ans += F[i - 1] * F[N - i - 1] % MOD * (MOD - A[i]) % MOD;
  }
  ans %= MOD;
  cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007 
#define INF 10000000000000000
#define ff first
#define ss second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.141592653589793238462643383279
#define PYES cout<<"YES"<<endl
#define PNO cout<<"NO"<<endl
#define SB(a) sort(a.begin(),a.end(),greater<ll>());
#define SS(a) sort(a.begin(),a.end());
#define vll vector<ll>
#define vpll vector<pll>
vector<bool> prime;
vector<ll> fact,inv,primes,factors,pf;
void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
void factorize(ll a)
{
	factors.clear();
	for(ll i=1;i*i<=a;i++)
	{
		if (i*i==a) factors.pb(i);
		else if (a%i==0)
		{
			factors.pb(i);
			factors.pb(a/i);
		}
	}
	sort(factors.begin(),factors.end());
}
ll power(ll a,ll b)
{
	if(a==1||b==0)	return 1;
	ll c=power(a,b/2);
	ll res=1;
	res=c*c;
	if(res>=mod)	res%=mod;
	if(b%2)	res*=a;
	if(res>=mod)	res%=mod;
	return res;
}
ll modInv(int a)
{
	return power(a,mod-2);
}
void factorial(ll n)
{
	fact.resize(n+1);
	fact[0]=1;
	for(ll i=1;i<=n;i++)
	{
		fact[i]=fact[i-1]*i;
		if(fact[i]>=mod)	fact[i]%=mod;
	}
}
void InvFactorial(ll n)
{
	inv.resize(n+1);
	inv[0]=1;
	for(ll i=1;i<=n;i++)	inv[i]=modInv(fact[i]);
}
ll ncr(ll n,ll r)
{
	if(n<r||n<0||r<0)	return 0;
	ll b=inv[n-r];
	ll c=inv[r];
	ll a=fact[n]*b;
	if(a>=mod)	a%=mod;
	a*=c;
	if(a>=mod)	a%=mod;
	return a;
}
void remove_duplicates(vpll &v)
{
	sort(v.begin(),v.end());
	ll _size=unique(v.begin(),v.end())-v.begin();
	v.resize(_size);
}
unsigned ll gcd(unsigned ll u, unsigned ll v)
{
    if(u==0||v==0) return max(u,v);
    unsigned ll shift=__builtin_ctz(u|v);
	u>>=__builtin_ctz(u);
    do{
    	v>>=__builtin_ctz(v);
    	if(u>v)	swap(u,v);
    	v-=u;
    }while(v!=0);
    return u<<shift;
}
void sieve(ll n)
{
    prime.assign(n+1,1);
	prime[1]=false;
    for(ll p=2;p*p<=n;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<=n;i+=p)	prime[i]=false;
		}
	}	
    for(ll i=2;i<n+1;i++)
	{
		if(prime[i]) primes.push_back(i);
	} 
}
void prime_sieve(ll n)
{
	pf.assign(n+1,0);
	rep(i,n+1) pf[i]=i;
	for(ll i=2;i<=n;i++)
	{
		if (pf[i]==i)
		{
			for(ll j=i;j<=n;j+=i) pf[j]=i;
		}
	}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
// Always remember: if (condition) if (condition) statement; This doesn't work !!
// Always increase boundaries for global or frequency questions
// pow((ll)10,i) doesn't work sometimes. It is better to use multiple of 10 in arrays. Always remember this.
// delete values when defining global if there are multiple testcases
// don't try to be smart and make stupid mistakes
void solve()
{
	ll n;
	cin>>n;
	vll a(n);
	rep(i,n) cin>>a[i];
	if (n==1)
	{
		cout<<a[0];
		return;
	}
	ll sum=0;
	vll dp(n+5,0);
	dp[0]=1,dp[1]=1;
	for(ll i=2;i<=n+4;i++) dp[i]=dp[i-1]+dp[i-2],dp[i]%=mod;
	rep(i,n)
	{
		if (i==0) sum+=dp[n-i]*a[i];
		else
		{
			ll p=dp[n-i]*dp[i];
			p%=mod;
			p-=dp[n-i-1]*dp[i-1];
			if (p<0)
			{
				ll q=(-p);
				q=(q+mod-1)/mod;
				p+=q*mod;
				p%=mod;
			}
			p%=mod;
			p*=a[i];
			p%=mod;
			sum+=p;
			sum%=mod;
		}
		sum%=mod;
	}
	cout<<sum<<endl;
}
int main()
{
	fast();
	ll T=1;
	//cin>>T;
	for(ll z=1;z<=T;z++) solve();
}