#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)

template<typename T1> 
void dbg_pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    cout << "{";
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "}" : " ");
    }
}
void dbg_pr(string V) {cout << "\"" << V << "\"";}
template<typename T1> 
void dbg_pr(T1 V) {cout << V;}
template<typename T1, typename T2> 
void dbg_pr(map<T1, T2> M) {
    cout << "{";
    for(const auto m : M) {
        dbg_pr(m.first);
        cout << ":";
        dbg_pr(m.second);
        cout << ",";
    }
    cout << "}";
}
#ifdef _OLIMPOLOCAL
    #define dbg(...) cerr << "\033[1;36m[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define dbg(...) 1337
#endif
void debug_out() { cout << "\033[0m\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " "; dbg_pr(A); debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
void setupFastCin() {ios::sync_with_stdio(false);cin.tie(0);}

template<typename T1> 
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1> 
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
template<typename T1> 
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
#define PLL pair<ll, ll>
template<typename T1> 
T1 gcd(const T1 &a, const T1 &b) {
    if (a == 0 || b == 0) return a + b;
    return gcd(b, a %b);
}
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------

#define MAX 1000000
#define MAXP 21
//#define MOD 998244353ll
#define MOD 1000000007ll

long long power(long long x, long long n) {
    long long p = x;
    long long s = 1;
    while (n > 0) {
        if (n & 1) s = (s * p) % MOD;
        p = (p * p) % MOD;
        n /= 2;
    }
    return s;
}


int n;
ll x;
ll C[2][100005];
ll D[2][100005];
void solve() {
    cin >> n;
    
    C[0][0] = 1;
    cin >> D[0][0];
    D[1][0] = C[1][0] = 0;
    reps(i, 1, n) {
        cin >> x;
        C[0][i] = C[0][i-1] + C[1][i-1]; 
        C[1][i] = C[0][i-1];
        C[0][i] %= MOD;
        C[1][i] %= MOD;

        D[0][i] = D[0][i-1] + D[1][i-1] + (C[0][i] * x) % MOD; 
        D[1][i] = D[0][i-1] - (C[1][i] * x) % MOD;
        D[0][i] %= MOD;
        D[1][i] %= MOD;
        dbg(D[0][i], D[1][i]);
    }
    out((D[0][n-1] + D[1][n-1] + MOD + MOD + MOD) % MOD)

}

int main() {
    setupFastCin();
    int T = 1;
#ifdef _OLIMPOLOCAL
    cin >> T;
#endif
    reps(t, 1, T + 1){
        solve();
    }
        
    return 0;
}
#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    vector<long long> dp(2, 0);
    vector<long long> cnts(2, 0);
    auto ndp = dp;
    auto ncnts = cnts;
    cnts[1] = 1;

    const long long MOD = 1000000007;
    for (auto x : A) {
        fill(ndp.begin(), ndp.end(), 0);
        fill(ncnts.begin(), ncnts.end(), 0);

        {
            ncnts[0] = (cnts[0] + cnts[1]) % MOD;
            ndp[0] = (dp[0] + cnts[0] * 1LL * x % MOD) % MOD;
            (ndp[0] += (dp[1] + cnts[1] * 1LL * x % MOD) % MOD) %= MOD;
        }
        {
            ncnts[1] = cnts[0];
            ndp[1] = (dp[0] - cnts[0] * 1LL * x % MOD + MOD) % MOD;
        }
        swap(ndp, dp);
        swap(ncnts, cnts);
    }
    long long res = 0;
    res += dp[0];
    res += dp[1];
    res %= MOD;

    cout << res << '\n';

    return 0;
}