#include <bits/stdc++.h>
using namespace std;
int a[200001], fact[200001], inv_fact[200001];
int ModExp(int a, int n) {
  int ans = 1 % 1000000007;
  while (n) {
    if (n % 2) ans = (1ll * ans * a) % 1000000007;
    a = (1ll * a * a) % 1000000007;
    n /= 2;
  }
  return ans;
}
int ModInverse(int a) { return ModExp(a, 1000000007 - 2); }
void Initialise() {
  fact[0] = inv_fact[0] = 1 % 1000000007;
  for (int i = 1; i < 200001; i++) {
    fact[i] = (1ll * i * fact[i - 1]) % 1000000007;
    inv_fact[i] = (1ll * ModInverse(i) * inv_fact[i - 1]) % 1000000007;
  }
}
int nCr(int n, int r) {
  if (n < 0 || r < 0 || n < r)
    return 0;
  else {
    int ans = fact[n];
    ans = (1ll * ans * inv_fact[r]) % 1000000007;
    ans = (1ll * ans * inv_fact[n - r]) % 1000000007;
    return ans;
  }
}
int main() {
  int n, k = 1, ans;
  Initialise();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (n > 1 && n % 2 == 1) {
    for (int i = 1; i < n; i++) {
      a[i] = (a[i] + k * a[i + 1]) % 1000000007;
      a[i] = (1000000007 + a[i]) % 1000000007;
      k *= -1;
    }
    n--;
  }
  if (n > 2) {
    int a1 = 0, a2 = 0, m = n / 2 - 1;
    for (int i = 0; i <= m; i++) {
      a1 = (a1 + 1ll * nCr(m, i) * a[2 * i + 1]) % 1000000007;
      a2 = (a2 + 1ll * nCr(m, i) * a[2 * i + 2]) % 1000000007;
    }
    if (n % 4 == 0) k *= -1;
    a[1] = a1, a[2] = a2;
  }
  for (int i = 1; i < n; i++) {
    a[i] = (a[i] + k * a[i + 1]) % 1000000007;
    a[i] = (1000000007 + a[i]) % 1000000007;
    k *= -1;
  }
  n--;
  ans = a[1];
  printf("%d\n", ans);
  return 0;
}
