#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 10, MOD = 1e9 + 7, MAXN = 1e5 + 10;
const long long inf = 4e18 + 10;
long long a[N], b[N], fac[N], inv[N], n, t = 1;
long long Pw(long long c, long long d) {
  if (d == 0) return 1;
  long long tmp = Pw(c, d / 2);
  tmp = 1ll * tmp * tmp % MOD;
  if (d % 2) return 1ll * tmp * c % MOD;
  return tmp;
}
void Get(long long x, long long c) {
  n -= c;
  while (c) {
    for (long long i = 1; i < x; i++) b[i] = a[i] + t * a[i + 1], t *= -1;
    for (long long i = 1; i < x; i++) a[i] = b[i];
    c--, x--;
  }
}
long long Choose(long long c, long long d) {
  if (!c || !(d - c)) return 1;
  long long ret = 1ll * fac[d] * inv[c] % MOD;
  return 1ll * ret * inv[d - c] % MOD;
}
int32_t main() {
  fac[0] = 1;
  for (long long i = 1; i < N; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
  inv[N - 1] = Pw(fac[N - 1], MOD - 2);
  for (long long i = N - 2; i >= 1; i--)
    inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
  long long ans = 0;
  scanf("%d", &n);
  for (long long i = 1; i <= n; i++) scanf("%d", &a[i]);
  Get(n, (n - 1) % 4);
  for (long long i = 1; i <= n; i++) {
    if (i % 2 == 1) ans = (ans + 1ll * Choose(i / 2, n / 2) * a[i] % MOD) % MOD;
  }
  return cout << (ans + MOD) % MOD, 0;
}
