#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long mod = 1000000007LL;
long long a[N], fac[N], invfac[N], inv[N];
void init() {
  inv[1] = 1;
  fac[0] = fac[1] = 1;
  invfac[0] = invfac[1] = 1;
  for (int i = 2; i <= 200000; ++i) {
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    fac[i] = fac[i - 1] * i % mod;
    invfac[i] = invfac[i - 1] * inv[i] % mod;
  }
}
long long cmb(int a, int b) {
  return fac[a] * invfac[b] % mod * invfac[a - b] % mod;
}
long long b[5][5];
int n;
void solve() {
  if (!n) {
    printf("%I64d\n", b[0][0]);
    return;
  }
  if (n == 1) {
    printf("%I64d\n", (b[0][0] + b[0][1]) % mod);
    return;
  }
  if (n == 2) {
    long long ans = (b[0][0] + b[0][1] + b[0][1] - b[0][2]) % mod;
    if (ans < 0) ans += mod;
    printf("%I64d\n", ans);
    return;
  }
  long long ans = (b[0][0] - b[0][1] + b[0][2] - b[0][3]) % mod;
  if (ans < 0) ans += mod;
  printf("%I64d\n", ans);
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%I64d", a + i);
  int t = (--n) >> 2;
  if (!t) {
    for (int i = 0; i <= n; ++i) b[0][i] = a[i];
    solve();
    return 0;
  }
  n &= 3;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= (t << 2); j += 2)
      (b[0][i] += a[i + j] * cmb(t << 1, j >> 1)) %= mod;
  }
  solve();
  return 0;
}
