#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int N;
vector<int> v;
vector<int> vk;
int ft[200005], inv[200005];
int pw(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return ret;
}
int comb(int n, int k) {
  if (k < 0 || k > n) return 0;
  return 1ll * ft[n] * inv[k] % mod * inv[n - k] % mod;
}
vector<int> trans(vector<int> a, int sign) {
  vector<int> b;
  for (int i = (1), _b = (a.size() - 1); i <= _b; i++)
    b.push_back((a[i - 1] + 1ll * sign * a[i]) % mod), sign = mod - sign;
  return b;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  int x;
  for (int i = (1), _b = (N); i <= _b; i++) cin >> x, v.push_back(x);
  ft[0] = 1;
  for (int i = (1), _b = (N); i <= _b; i++) ft[i] = 1ll * i * ft[i - 1] % mod;
  for (int i = (0), _b = (N); i <= _b; i++) inv[i] = pw(ft[i], mod - 2);
  int sz = N % 4, n = N / 4 * 2;
  if (sz == 0) sz = 4, n -= 2;
  for (int i = (0), _b = (sz - 1); i <= _b; i++) {
    x = 0;
    for (int k = 0; k <= n; ++k)
      x = (x + 1ll * v[i + 2 * k] * comb(n, k)) % mod;
    vk.push_back(x);
  }
  int sign = 1;
  while (vk.size() > 1) {
    vk = trans(vk, sign);
    if (vk.size() & 1) sign = mod - sign;
  }
  cout << vk[0] << endl;
  return 0;
}
