#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, MOD = 1e9 + 7;
int mpow(int x, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res = 1LL * res * x % MOD;
    x = 1LL * x * x % MOD;
    n >>= 1;
  }
  return res;
}
int fac[N], rev[N];
int C(int x, int y) { return 1LL * fac[x] * rev[y] % MOD * rev[x - y] % MOD; }
int a[N], b[N];
int main() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) fac[i] = 1LL * fac[i - 1] * i % MOD;
  for (int i = 0; i < N; ++i) rev[i] = mpow(fac[i], MOD - 2);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int tar = n % 4;
  if (n % 4 == 3) tar = 1;
  if (n % 4 == 0) tar = 1;
  int las = 1;
  while (n % 4 != tar) {
    for (int i = 1; i < n; ++i) {
      a[i] = (a[i] + las * a[i + 1]) % MOD;
      a[i] = (a[i] + MOD) % MOD;
      las *= -1;
    }
    n--;
  }
  if (n % 4 == 1) {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (i % 2 == 0) {
        (ans += 1LL * a[i + 1] * C(n / 2, i / 2) % MOD) %= MOD;
      }
    }
    printf("%d\n", ans);
  } else {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      (ans += 1LL * a[i + 1] * C(n / 2 - 1, i / 2) % MOD) %= MOD;
    }
    printf("%d\n", ans);
  }
}
