#include <bits/stdc++.h>
using namespace std;
using LL = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename S>
using P = pair<T, S>;
template <class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
using LD = long double;
template <typename T, typename S>
void check(T& a, S& b) {
  if (a >= b) {
    a %= b;
  }
}
template <typename T>
T gcd(T u, T v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
LL mulmod(LL a, LL b, LL m) {
  check(a, m);
  check(b, m);
  LL q = (LL)(((LD)a * (LD)b) / (LD)m);
  LL r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T, typename S>
T expo(T e, S n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T powerL(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
const int N = 200010;
const LL mod = (LL)1e9 + 7;
LL f[N], inv[N];
void pre() {
  f[0] = inv[0] = f[1] = inv[1] = 1;
  for (LL i = 2; i < N; i++) {
    f[i] = mulmod(f[i - 1], i, mod);
    inv[i] = powerL(f[i], mod - 2, mod);
  }
  return;
}
LL ncr(LL n, LL r) {
  LL ans = mulmod(f[n], inv[n - r], mod);
  return mulmod(ans, inv[r], mod);
}
LL solve(V<LL>& a) {
  LL n = (LL)a.size();
  LL x = (n >> 1) - 1;
  V<LL> co;
  for (LL i = 0; i < (LL)(x / 2) + 1; i++) {
    LL t = ncr(x, i);
    co.push_back(t);
    co.push_back(t);
  }
  if ((LL)co.size() * 2 > n) co.pop_back();
  auto temp = co;
  reverse(temp.begin(), temp.end());
  for (LL& i : temp) co.push_back(i);
  if (n % 4 == 0) {
    for (LL i = 1; i < n; i += 2) co[i] = -co[i];
  }
  LL ans = 0;
  for (LL i = 0; i < (LL)n; i++) {
    LL t = mulmod(a[i], co[i], mod);
    ans = (ans + t);
    ans %= mod;
    ans = (ans + mod) % mod;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  ;
  pre();
  LL n;
  cin >> n;
  V<LL> a(n);
  for (LL i = 0; i < (LL)n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[0] << '\n';
    return 0;
  }
  if (n & 1) {
    V<LL> t;
    for (LL i = 0; i < (LL)n - 1; i++) {
      t.push_back(a[i] + (2 * (!(i & 1)) - 1) * a[i + 1]);
    }
    a = t;
  }
  cout << solve(a) << '\n';
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
