#include <bits/stdc++.h>
using namespace std;
long double esp = 1e-11;
const long double PI = acos((long double)-1);
const long long int INF = 0x3f3f3f3fll;
const int MOD = 1000000007ll;
const int maxn = 200001;
int inv[maxn], pin_inv[maxn], pin[maxn];
void initCab(int N) {
  inv[0] = pin[0] = pin_inv[0] = inv[1] = pin[1] = pin_inv[1] = 1;
  for (int x = 2; x <= N; x++) {
    inv[x] = (long long int)(MOD - MOD / x) * inv[MOD % x] % MOD;
    pin[x] = (long long int)pin[x - 1] * x % MOD;
    pin_inv[x] = (long long int)pin_inv[x - 1] * inv[x] % MOD;
  }
}
long long int Cab(int n, int m) {
  return (long long int)pin[n] * pin_inv[m] % MOD * pin_inv[n - m] % MOD;
}
long long int m[maxn], ans[10];
int main() {
  initCab(maxn - 1);
  int n;
  scanf("%d", &n);
  for (int x = 1; x <= n; x++) scanf("%d", &m[x]);
  int f = 1;
  if (n % 2 == 0) {
    for (int x = 1; x < n; x++)
      if (x & 1)
        m[x] = (m[x] + m[x + 1]) % MOD;
      else
        m[x] = (m[x] - m[x + 1]) % MOD;
    n--;
    f = 0;
  }
  int time = (n - 1) / 4 * 4;
  for (int x = 1; x <= n - time; x++) {
    ans[x] = 0;
    for (int y = 1; y <= time + 1; y++)
      if (y & 1) {
        ans[x] = (ans[x] + m[x + y - 1] * Cab(time / 2, y / 2)) % MOD;
      }
  }
  n -= time;
  while (n > 1) {
    for (int x = 1; x < n; x++) {
      if (f & 1)
        ans[x] = (ans[x] + ans[x + 1]) % MOD;
      else
        ans[x] = (ans[x] - ans[x + 1]) % MOD;
      f ^= 1;
    }
    n--;
  }
  ans[1] = (ans[1] % MOD + MOD) % MOD;
  printf("%I64d\n", ans[1]);
  return 0;
}
