#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
int N, A[MAXN];
long long mod_power(long long x, long long N, long long MOD = ::MOD) {
  long long res = 1;
  for (; N > 0; N >>= 1, x = x * x % MOD)
    if (N & 1) res = res * x % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  int positive = 1;
  for (; (N & 3) ^ 1; --N) {
    for (int i = 1; i < N; ++i) {
      if (positive)
        A[i] = (A[i] + A[i + 1]) % MOD;
      else
        A[i] = (A[i] - A[i + 1] + MOD) % MOD;
      positive ^= 1;
    }
  }
  long long C = 1, p = N >> 1, ans = A[1];
  for (int i = 1; i <= p; ++i) {
    C = C * (p - i + 1) % MOD * mod_power(i, MOD - 2) % MOD;
    ans = (ans + C * A[i << 1 | 1]) % MOD;
  }
  cout << ans << endl;
  return 0;
}
