#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
using namespace std;

//take care of long long

//fast I/O 
auto optimizer = []() {  // makes I/O fast
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();

//seive
ll N = 1e5;
vll lpf(N+1,0);
void leastPrimeFactor()
{
    lpf[1] = 1;
    for (ll i = 2; i <= N; i++)
    {
        if(lpf[i] == 0)
        {
            lpf[i] = i;
            for (ll j = 2*i; j <= N; j += i)
            	if (lpf[j] == 0)
                	lpf[j] = i;
        } 
    }
}

int main()
{
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		cout<<max(a+b,max(b+c,c+a))<<endl;
	    
	}
	return 0;
}
//                        YATIN KWATRA

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")


#define ll                      long long
#define ar                      array
#define sz(v)                   (int)(v.size())
#define inf                     1e18
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define pq                      priority_queue
#define uomii                   unordered_map<int,int,best_hash>
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795
#define cz(x)                   63 - __builtin_clzll(x)

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


struct best_hash {
	static uint64_t splitmix64(uint64_t x) {

		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

const int N = 1e5 + 5;
ar<int, 2> dp[2][N]; // {sum,cnt}
int v[N];
int n;

ar<int, 2> ways(int sign, int pos) {
	if (pos == n) return {0, 1};
	ar<int, 2>& ans = dp[sign][pos];
	if (ans[0] != (int)(-1e18)) return ans;
	ans = {0, 0};

	// put a plus before this element

	auto cur = ways(0, pos + 1);
	ans[0] += (v[pos] * cur[1]) % mod;
	ans[0] %= mod;
	ans[0] += cur[0];
	ans[0] = (ans[0] % mod + mod) % mod;
	ans[1] = (ans[1] + cur[1]) % mod;

	// put a minus if allowed before this

	if (!sign) {
		auto x = ways(1, pos + 1);
		ans[0] -= (v[pos] * x[1]) % mod;
		ans[0] %= mod;
		ans[0] += x[0];
		ans[0] = (ans[0] % mod + mod) % mod;
		ans[1] = (ans[1] + x[1]) % mod;
	}

	return ans;
}

void solve()
{
	cin >> n;
	fo(i, 0, n - 1) cin >> v[i];
	fo(i, 0, 1) {
		fo(j, 0, n) dp[i][j] = { (int)(-1e18), (int)(-1e18)};
	}
	auto ans = ways(0, 1);
	ans[0] += (ans[1] * v[0]) % mod;
	ans[0] = (ans[0] % mod + mod) % mod;
	cout << ans[0];
}

signed main() {

	FIO
	int t;
	t = 1;
//	cin >> t;
	fo(i, 0, t - 1) {
		solve();
	}
	return 0;
}
