#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T& a, const T& b) {
  return a < b ? (a = b, true) : false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  return b < a ? (a = b, true) : false;
}
int N;
const int MAX_N = 200000;
vector<long long> A, B;
const long long MOD = 1e9 + 7;
long long fact[MAX_N + 1];
void do_step(vector<long long>& v, int sign) {
  vector<long long> res(v.size());
  for (int i = (int)(0); i < (int)(v.size()); i++) {
    if (i % 2 == 0) {
      res[i] += v[i] * sign;
      res[i] = (res[i] % MOD + MOD) % MOD;
    } else {
      res[i] += v[i] * -sign;
      res[i] = (res[i] % MOD + MOD) % MOD;
    }
    if (i + 1 < v.size()) {
      res[i + 1] += v[i];
      res[i + 1] = (res[i + 1] % MOD + MOD) % MOD;
    }
  }
  v.swap(res);
}
long long mod_pow(long long x, long long y = MOD - 2) {
  long long res = 1;
  while (y) {
    if (y & 1) (res *= x) %= MOD;
    (x *= x) %= MOD;
    y >>= 1;
  }
  return res;
}
int main() {
  scanf("%d", &N);
  int curr = N % 2;
  A.assign(N, 0);
  for (int i = (int)(0); i < (int)(N); i++) {
    scanf("%lld", &A[i]);
  }
  fact[0] = 1;
  for (int i = (int)(1); i < (int)(MAX_N + 1); i++)
    fact[i] = fact[i - 1] * i % MOD;
  int len = (N - 1) / 4 * 4 + 1;
  for (int i = (int)(0); i < (int)(N); i++)
    if (i + len <= N) {
      B.push_back(0);
      for (int j = (int)(i); j < (int)(i + len); j++)
        if ((j - i) % 2 == 0) {
          long long x = (j - i) / 2, y = len / 2 - x;
          long long c =
              fact[len / 2] * mod_pow(fact[x]) % MOD * mod_pow(fact[y]) % MOD;
          (c *= A[j]) %= MOD;
          (B.back() += c) %= MOD;
        }
    }
  for (int i = (int)(0); i < (int)((N - 1) % 4); i++) {
    do_step(B, (curr + i) % 4 < 2 ? -1 : 1);
  }
  printf("%lld\n", B.back());
  return 0;
}
