#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200003, MOD = 1e9 + 7;
int n;
long long a[MaxN];
long long inv[MaxN];
template <typename T>
inline T mod(const T& x) {
  T ret = x % MOD;
  if (ret < 0) ret += MOD;
  return ret;
}
inline long long fastpow(long long a, long long x) {
  long long ret = 1;
  while (x > 0) {
    if (x & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD, x >>= 1;
  }
  return ret;
}
inline void work(int& flag) {
  for (int i = 1; i < n; ++i) {
    a[i] = mod(a[i] + a[i + 1] * flag);
    flag = -flag;
  }
  n--;
}
long long C[MaxN], b[MaxN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", a + i);
  for (int i = 1; i <= n; ++i) inv[i] = fastpow(i, MOD - 2);
  if (n <= 10) {
    int flag = 1;
    while (n > 1) work(flag);
    printf("%I64d\n", mod(a[1]));
    return 0;
  }
  if (n % 2 == 0) {
    int flag = 1;
    work(flag);
    work(flag);
    work(flag);
  }
  int rounds = (n - 1) / 4, m = rounds * 2;
  b[0] = C[0] = 1;
  for (int i = 1; i <= m; ++i)
    C[i] = (((C[i - 1] * (m - i + 1)) % MOD) * inv[i]) % MOD, b[i * 2] = C[i];
  int k = m * 2;
  for (int i = 1; i <= n - k; i++) {
    long long t = 0;
    for (int j = 0; j <= k; j++) {
      t += mod(a[i + j] * b[j]);
      t %= MOD;
    }
    a[i] = t;
  }
  n = n - k;
  int flag = 1;
  while (n > 1) work(flag);
  printf("%I64d\n", a[1]);
  return 0;
}
