#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
long long fac[maxn], a[maxn];
int n;
void init() {
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
  }
}
long long quick(long long a, long long k) {
  long long e = 1;
  while (k) {
    if (k & 1) (e *= a) %= mod;
    (a *= a) %= mod;
    k >>= 1;
  }
  return e;
}
long long calc(int n, int k) {
  return (fac[n] * quick(fac[n - k], mod - 2) % mod) * quick(fac[k], mod - 2) %
         mod;
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  if (n & 1) {
    int odd = 1;
    for (int i = 1; i <= n - 1; i++) {
      a[i - 1] = a[i] + odd * a[i + 1];
      odd *= (-1);
    }
    n--;
    for (int i = n; i >= 1; i--) a[i] = a[i - 1];
  }
  long long ans = 0;
  int odd = 1;
  for (int i = 1; i <= n; i++) {
    (ans += (a[i] * odd * calc(n / 2 - 1, (i - 1) / 2)) % mod) %= mod;
    if (n % 4 == 0) odd = -odd;
  }
  if (!n) ans = a[1];
  (ans += mod) %= mod;
  printf("%lld\n", ans);
}
