#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 123456, mod = 1000000007;
int n;
int a[maxn], fib[maxn];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n) cin >> a[i];
}

void solve()
{
	int fu = 1;
	int ans = 0;
	fib[0] = fib[1] = 1;
	for (int i = 2; i <= n; ++i)
		fib[i] = (fib[i - 1] + fib[i - 2]) % mod;
	ans = a[1] * fib[n] % mod;
	for (int i = 2; i <= n; ++i)
	{
		int neg = fib[i - 2] * fib[n - i] % mod;
		int coef = (fib[n] - neg - neg + mod + mod) % mod;
		ans = (ans + a[i] * coef % mod) % mod;
	}
	cout << ans << '\n';
}
main()
{
	input();
	solve();
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int mod=1000000007;
  int N;cin>>N;
  vector<vector<int>>V(N,vector<int>(2));//0は正、1は負
  vector<int>J(N);J[0]=1;J[1]=1;
  for(int X=2;X<N;X++){
    J[X]=J[X-1]+J[X-2];J[X]%=mod;
  }
  for(int X=0;X<N;X++){
    int A;cin>>A;
    if(X==0){
      V[X][0]=A;V[X][1]=A;
    }
    else if(X==1){
      V[X][0]=V[X-1][0]+A;V[X][0]%=mod;
      V[X][1]=V[X-1][1]-A;
      if(V[X][1]<0){
        V[X][1]%=mod;
        V[X][1]+=mod;
      }
      V[X][1]%=mod;
    }
    else{
      V[X][0]=V[X-1][0]+V[X-1][1]+A*J[X];V[X][0]%=mod;
      V[X][1]=V[X-1][0]-A*J[X-1];
      if(V[X][1]<0){
        V[X][1]%=mod;
        V[X][1]+=mod;
      }
      V[X][1]%=mod;
    }
    //cout<<V[X][0]<<" "<<V[X][1]<<endl;
  }
  if(N==1)cout<<V[N-1][0]<<endl;
  else cout<<(V[N-1][0]+V[N-1][1])%mod<<endl;
}