6
58376259 643910770 5887448 757703054 544067926 902981667
 5
585325539 365329221 412106895 291882089 564718673
 7
941492387 72235422 449924898 783332532 378192988 592684636 147499872
 1
1
 16
985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082
 1
1000000000
 19
519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759
 17
458679894 912524637 347508634 863280107 226481104 787939275 48953130 553494227 458256339 673787326 353107999 298575751 436592642 233596921 957974470 254020999 707869688
 2
500000004 500000003
 4
702209411 496813081 673102149 561219907
 18
341796022 486073481 86513380 593942288 60606166 627385348 778725113 896678215 384223198 661124212 882144246 60135494 374392733 408166459 179944793 331468916 401182818 69503967
 3
524125987 923264237 374288891


676517605
 
974257995
 
328894634
 
1
 
347261016
 
1000000000
 
265109293
 
769845668
 
0
 
317278572
 
773499683
 
996365563

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
const long long mod = 1e9+7;
// const long long mod = 998244353;
const long long int special_prime = 982451653;
using namespace std;
// DEBUGGER
// *
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
// *
// DEBUGGER

#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define mp make_pair
#define pb emplace_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
#define sz(x) (int)((x).size())
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define distance(a,b,c,d) ((a-c)*1LL*(a-c)+(b-d)*1LL*(b-d))
#define range(i,x,y) ((x <= i) && (i <= y))
#define SUM(a) accumulate(a.begin(),a.end(),0LL)
#define lb lower_bound
#define ub upper_bound
#define REV reverse
#define seive(N) int pr[N]; void preSieve(){for(int i = 2; i < N; ++i){if(!pr[i])for(int j = i; j < N; j+=i)pr[j]=i;}}
#define modInv(N) ll inv[N]; void preModInv(){inv[0]=0;inv[1]=1;for(int i = 2; i < N; ++i)inv[i] = mod-mod/i*inv[mod%i]%mod;}
#define fact(N) ll fact[N]; void preFact(){fact[0] = 1,fact[1] = 1; for(int i = 2; i < N; ++i)fact[i]=fact[i-1]*i%mod;}
#define inFact(N) ll ifact[N]; void preiFact(){ifact[1] = 1; for(int i = 2; i < N; ++i)ifact[i]=ifact[i-1]*inv[i]%mod;}

// Randomization



// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T,U> &rhs){in >> rhs.first;in >> rhs.second;return in;}
template<class T, class U>ostream& operator<<(ostream& out,const pair<T,U> &rhs){out << rhs.first;out << " ";out << rhs.second;return out;}
template<class T, class U>pair<T,U> operator+(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first+b.first,a.second+b.second);}
template<class T, class U>pair<T,U> operator-(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first-b.first,a.second-b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a){for(auto &i: a)cin >> i;return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a){for(auto &i: a)cout << i << " ";return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a){for(auto &i: a)cout << i << " ";return out;}
// MAP
template<class T,class U>ostream& operator<<(ostream& out, const map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << ")\n";return out;}
template<class T,class U>ostream& operator<<(ostream& out, const unordered_map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << ")\n";return out;}

using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const long long N = 2e5 + 100;
const long long inf = 1e9;
const long double pi = acos(-1);

ll a[N];
ll fct[N],inv[N];

ll ncr(ll n, ll r){
    if(n < 0 || n < r || r < 0)return 0;
    return fct[n]*inv[n-r]%mod*inv[r]%mod;
}

void solve(int test_case){
    int n;
    cin >> n;
    loop(i,0,n)cin >> a[i];
    ll ans = 0;
    if(n % 4 == 0){
        loop(i,0,n){
            if(i&1)ans-=ncr((n-2)/2,i/2)*a[i]%mod;
            if(i&1^1)ans+=ncr((n-2)/2,i/2)*a[i]%mod;
            if(ans >= mod)ans-=mod;
            if(ans < 0)ans+=mod;
        }
    }
    else if(n % 4 == 1){
        loops(i,0,n,2){
            ans+=ncr((n-1)/2,i/2)*a[i]%mod;
            if(ans >= mod)ans-=mod;
        }
    }
    else if(n % 4 == 2){
        loop(i,0,n){
            ans+=ncr((n-2)/2,i/2)*a[i]%mod;
            if(ans >= mod)ans-=mod;
        }
    }
    else if(n % 4 == 3){
        int ch[3] = {2,1,-1};
        loop(i,0,n){
            if(!i)ans+=ncr((n-3)/2,i/2)*a[i]%mod;
            else ans+=ch[(i-1)%3]*ncr((n-3)/2,i/2)*a[i]%mod;
            if(ans >= mod)ans-=mod;
            if(ans < 0)ans+=mod;
        }
    }
    cout << ans ;
}

ll power(ll a, ll n){
    if(n == 0 || a == 1)return 1;
    if(n == 1)return a;
    ll p = power(a,n/2);
    p = p * p % mod;
    if(n&1)p = p * a % mod;
    return p;
}

int main(){
	FAST
    fct[0] = 1;
    inv[0] = 1;
    loop(i,1,N){
        fct[i] = i * 1LL * fct[i-1] % mod;
        inv[i] = inv[i-1] * power(i,mod-2);
    }
	auto clk = clock();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int t = 1;
	//cin >> t;
	loop(i,1,t+1)solve(i);
	#ifdef LOCAL
		cout << "\n\nTIME ELAPSED : " << double(clock() - clk)/CLOCKS_PER_SEC * 1000.0 << " ms.\n";
	#endif
}
