#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
long long int pow(long long int base, long long int exp, int m) {
  if (exp == 0)
    return 1;
  else if (exp == 1)
    return base;
  long long int root = pow(base, exp >> 1, m);
  if ((exp & 1) == 0)
    return (root * root) % m;
  else
    return (((root * root) % m) * base) % m;
}
long long int fact[(int)1e6];
long long int ncr(int n, int r) {
  return (((fact[n] * pow(fact[n - r], mod - 2, mod)) % mod) *
          pow(fact[r], mod - 2, mod)) %
         mod;
}
void solve(long long int *a, int n) {
  if (n == 2) {
    cout << (a[0] + a[1]) % mod;
    return;
  }
  int last = 1, i, j;
  for (i = n; i > 2; i--) {
    if (i % 2 == 0) {
      last *= -1;
    }
  }
  j = n / 2;
  long long int p1 = 0, p2 = 0;
  for (i = 0; i < n; i += 2) {
    long long int v = ncr(j - 1, i / 2);
    v = v * a[i];
    v %= mod;
    p1 = (p1 + v) % mod;
  }
  for (i = 1; i < n; i += 2) {
    long long int v = ncr(j - 1, i / 2);
    v = (v * a[i]) % mod;
    p2 = (p2 + v) % mod;
  }
  p2 *= last;
  p1 += p2;
  p1 %= mod;
  if (p1 < 0) p1 += mod;
  cout << p1;
}
int main() {
  int t, n, m, i, j, k, l, p;
  cin >> n;
  fact[0] = 1;
  for (i = 1; i < (int)3e5; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  long long int a[n];
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
  }
  if (n == 1) {
    cout << a[0];
    return 0;
  }
  if (n % 2 == 0)
    solve(a, n);
  else {
    long long int tmp[n - 1];
    p = 1;
    for (i = 0; i < n - 1; i++) {
      tmp[i] = a[i] + (p * a[i + 1]);
      tmp[i] %= mod;
      if (tmp[i] < 0) tmp[i] += mod;
      p *= -1;
    }
    solve(tmp, n - 1);
  }
  return 0;
}
