#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const long long mod = 1000000007;
long long a[maxn], b[maxn], fac[maxn];
long long qsm(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) scanf("%lld", &a[i]), b[i] = a[i];
  if (n == 1) {
    printf("%lld\n", a[0]);
    return 0;
  }
  if (n & 1) {
    n--;
    int flag = 0;
    for (long long i = 0; i < n; i++) {
      if (!flag)
        a[i] = (b[i] + b[i + 1]) % mod;
      else
        a[i] = (b[i] - b[i + 1] + mod) % mod;
      flag ^= 1;
    }
  }
  n = n / 2 - 1;
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  long long ans1 = 0, ans2 = 0;
  for (long long i = 0; i <= n; i++) {
    long long xishu = (fac[n] * qsm(fac[i] * fac[n - i] % mod, mod - 2)) % mod;
    (ans1 += xishu * a[i * 2] % mod) %= mod;
    (ans2 += xishu * a[i * 2 + 1] % mod) %= mod;
  }
  if (n & 1)
    ans1 = (ans1 - ans2 + mod) % mod;
  else
    ans1 = (ans1 + ans2) % mod;
  printf("%lld\n", ans1);
}
