#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
using ll = long long;
const ll MOD = 1e9 + 7;
ll n;
ll a[N];
ll powMod(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return r;
}
ll inverso(ll a) { return powMod(a, MOD - 2); }
ll facts[N];
ll factsInv[N];
void prepara() {
  facts[0] = factsInv[0] = 1;
  for (int i = 1; i < N / 2; i++) {
    facts[i] = facts[i - 1] * i % MOD;
    factsInv[i] = factsInv[i - 1] * inverso(i) % MOD;
  }
}
ll coefBin(ll n, ll k) {
  ll num = facts[n];
  ll den = factsInv[n - k] * factsInv[k] % MOD;
  return num * den % MOD;
}
int main() {
  prepara();
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  if (n == 1LL) {
    printf("%lld\n", a[0]);
    return 0;
  }
  ll totalOperaciones = n * (n - 1) / 2;
  bool ultimoEsSuma = (totalOperaciones % 2 == 1);
  if (n % 2 == 1) {
    for (int i = 0; i + 1 < n; i++) {
      if (i % 2 == 0) {
        a[i] = (a[i] + a[i + 1]) % MOD;
      } else {
        a[i] = (a[i] + MOD - a[i + 1]) % MOD;
      }
    }
    n--;
  }
  ll ultimos[2] = {};
  ll k = n / 2;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 2; j++) {
      ll x = coefBin(k - 1, i) * a[2 * i + j] % MOD;
      ultimos[j] = (ultimos[j] + x) % MOD;
    }
  }
  ll resultado;
  if (ultimoEsSuma) {
    resultado = (ultimos[0] + ultimos[1]) % MOD;
  } else {
    resultado = (ultimos[0] + MOD - ultimos[1]) % MOD;
  }
  printf("%lld\n", resultado);
}
