#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const long long mod = 1e9 + 7;
long long fac[MAXN];
long long num[MAXN];
long long quick_pow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%I64d", &num[i]);
  if (n == 1)
    printf("%I64d\n", num[0] % mod);
  else if (n == 2)
    printf("%I64d\n", (num[0] + num[1]) % mod);
  else {
    if (n & 1) {
      int op = 1;
      for (int i = 0; i < n - 1; ++i) {
        if (op == 1)
          num[i] = (num[i] + num[i + 1]) % mod;
        else
          num[i] = (num[i] - num[i + 1] + mod) % mod;
        op ^= 1;
      }
      n -= 1;
    }
    n = n / 2 - 1;
    fac[0] = 1LL;
    for (int i = 1; i <= n; ++i) fac[i] = (long long)i * fac[i - 1] % mod;
    long long lans = 0, rans = 0;
    for (int i = 0; i <= n; ++i) {
      long long co =
          fac[n] * quick_pow((fac[i] * fac[n - i]) % mod, mod - 2) % mod;
      lans = (lans + co * num[2 * i] % mod) % mod;
      rans = (rans + co * num[2 * i + 1] % mod) % mod;
    }
    if (n % 2 == 0)
      printf("%I64d\n", (lans + rans) % mod);
    else
      printf("%I64d\n", (lans - rans + mod) % mod);
  }
  return 0;
}
