#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 1e9 + 7;
long long a[N], f[N], invf[N];
long long qpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
void init() {
  f[0] = 1;
  invf[0] = 1;
  for (long long i = 1; i < N - 1; i++) {
    f[i] = f[i - 1] * i % mod;
    invf[i] = qpow(f[i], mod - 2);
  }
}
long long comb(int n, int m) {
  long long res = f[n] * invf[m] % mod;
  res = res * invf[n - m] % mod;
  return res;
}
int main() {
  init();
  int n;
  cin >> n;
  for (int i = (1); i < (n + 1); i++) {
    cin >> a[i];
  }
  int cnt = (n - 1) / 4;
  int t = 1, len;
  int mx = cnt * 4 + 1;
  len = n;
  while (len > mx) {
    len--;
    for (int j = (1); j < (len + 1); j++) {
      if (t)
        a[j] = (a[j] + a[j + 1]) % mod;
      else
        a[j] = (a[j] - a[j + 1]) % mod;
      t = 1 - t;
    }
  }
  long long ans = 0;
  int nn = mx / 2;
  for (int i = 1; i <= len; i += 2) {
    long long now = comb(nn, i / 2) * a[i] % mod;
    ans = (ans + now) % mod;
  }
  if (ans < 0) ans += mod;
  cout << ans;
  return 0;
}
