#include <bits/stdc++.h>
using namespace std;
char _buf[11 * 1000000 + 3];
int loadint() {
  fgets(_buf, 11 + 3, stdin);
  return atoi(_buf);
}
int loadvec(vector<long long>& v, int N) {
  int bufsize = 11 * N + 3;
  fgets(_buf, bufsize, stdin);
  v.resize(N);
  int i = 0;
  bool last = false;
  for (char* p = &_buf[0];;) {
    char* q = p;
    while (*q > ' ') ++q;
    if (*q == 0x0D || *q == 0x0A) last = true;
    *q = 0;
    v[i++] = atoi(p);
    if (last || i == N) break;
    p = q + 1;
  }
  return i;
}
const long long M = 1000000007LL;
long long ADD(long long x, long long y) { return (x + y) % M; }
long long SUB(long long x, long long y) { return (x - y + M) % M; }
long long MUL(long long x, long long y) { return x * y % M; }
long long POW(long long x, long long e) {
  long long v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
long long DIV(long long x, long long y) { return MUL(x, POW(y, M - 2)); }
void reduce(vector<long long>& a, int to) {
  int n = a.size();
  int pm = 1;
  for (int r = n; r > to; --r) {
    for (int i = 0; i < r - 1; ++i) {
      a[i] = (a[i] + pm * a[i + 1] + M) % M;
      pm = -pm;
    }
    a.pop_back();
  }
}
long long solve(vector<long long>& a) {
  int n = a.size();
  int rem = (n - 1) % 4;
  reduce(a, n - rem);
  n -= rem;
  long long lev = (n - 1 / 4), r = (n - 1) / 2, ac = 0LL;
  long long comb = 1LL;
  for (int i = 0; i < n; i += 2) {
    int k = i / 2;
    if (k >= 1) comb = DIV(MUL(comb, r - k + 1), k);
    ac = ADD(ac, MUL(a[i], comb));
  }
  return ac;
}
int main() {
  long long n = loadint();
  vector<long long> a(n);
  loadvec(a, n);
  if (n < 5) {
    reduce(a, 1);
    cout << a[0] << endl;
    return 0;
  }
  long long ans = solve(a);
  cout << ans << endl;
  return 0;
}
