#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += mod;
}
int mult(int a, int b) { return (long long)a * b % mod; }
void solve(int n) {
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  vector<int> inv(n + 1, 1), ifact(n + 1, 1), fact(n + 1, 1);
  for (int i = 0; i < (int)((int)(inv).size()); ++i)
    if (i >= 2) {
      inv[i] = mod - mult(mod / i, inv[mod % i]);
      assert(mult(i, inv[i]) == 1);
      ifact[i] = mult(ifact[i - 1], inv[i]);
      fact[i] = mult(fact[i - 1], i);
    }
  int sign = +1;
  while ((int)(a).size() > 1 && ((int)(a).size() % 2 == 1 || sign == -1)) {
    vector<int> na;
    for (int i = 0; i < (int)((int)(a).size() - 1); ++i) {
      int res = a[i];
      (sign == +1 ? add : sub)(res, a[i + 1]);
      na.push_back(res);
      sign *= -1;
    }
    a = na;
  }
  if ((int)(a).size() == 1) {
    cout << a[0] << endl;
    return;
  }
  n = (int)(a).size();
  assert(n % 2 == 0);
  vector<int> plast(2);
  for (int par = 0; par < (int)(2); ++par)
    for (int num = 0; num < (int)(n / 2); ++num) {
      int from = n / 2 - 1;
      int cur = mult(fact[from], mult(ifact[num], ifact[from - num]));
      add(plast[par], mult(cur, a[2 * num + par]));
    }
  (n % 4 == 2 ? add : sub)(plast[0], plast[1]);
  cout << plast[0] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  while (cin >> n) solve(n);
}
