#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout << fixed << setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on
const ll MODULO = 1000000007LL;
ll mod_minus(ll x, ll modval) {
    ll v = x % modval;
    if (v < 0) {
        v += modval;
    }
    return v;
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

ll n;
vector<ll> a;
ll memo[100005][2];
bool recdone[100005][2];
ll rec(ll i, ll cur) {
    if (i <= 1) {
        return 1;
    }

    if (recdone[i][cur]) return memo[i][cur];
    recdone[i][cur] = true;
    ll ans = 0;
    if (cur == 0) {
        ans = rec(i - 1, 1);
    } else {
        ans = rec(i - 1, 1) + rec(i - 1, 0);
    }
    return memo[i][cur] = mod(ans);
}
int main() {
    ioinit();
    cin >> n;
    a.resize(n);

    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (n == 2) {
        print(a[0] + a[0]);
        return 0;
    }
    if (n == 1) {
        print(a[0]);
        return 0;
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ll j = i - 1;

        ll plus = 0;
        if (i == 0) {
            plus = mod(rec(n - 1, 0) + rec(n - 1, 1));
        } else if (i == 1) {
            plus = mod(rec(n - 2, 0) + rec(n - 2, 1));
        } else if (i == n - 1) {
            plus = mod(rec(n - 2, 0) + rec(n - 2, 1));
        } else {
            plus = mod(mod(rec(n - j - 2, 0) + rec(n - j - 2, 1)) * mod(rec(j, 0) + rec(j, 1)));
        }

        ll minus = 0;
        if (i == 0) {
            minus = 0;
        } else {
            minus = mod(rec(n - 2 - j, 1) * rec(j, 1));
        }
        //print(i, plus, minus);
        ans = mod(ans + plus * a[i] - minus * a[i]);
    }
    print(ans);
}

#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int a[maxn];

int main() {
	long long *f = new long long[maxn];
	f++;

	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	
	f[-1] = 1;
	f[0] = 1;
	f[1] = 2;
	f[2] = 3;
	for (int i = 3; i <= n; ++i) {
		f[i] = f[i - 1] + f[i - 2];
		f[i] %= mod;
	}

	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i == 1) {
			ans += f[n - 1] * a[1];
		} else {
			ans += ((f[i - 2] * f[n - i] - f[i - 3] * f[n - i - 1]) % mod) * a[i];
		}
		ans %= mod;
	}

	if (ans < 0) {
		ans += mod;
	}

	printf("%lld\n", ans);
	
	f--;
	delete[] f;
	return 0;
}
