#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int fact[200005], rfact[200005];
int powmod(int b, int p) {
  int ans = 1;
  while (p) {
    if (p & 1) {
      ans = (1ll * ans * b) % mod;
    }
    p >>= 1;
    b = (1ll * b * b) % mod;
  }
  return ans;
}
int solve(vector<int> &a) {
  int n = a.size();
  if (n == 1) {
    return a[0];
  }
  if (n & 1) {
    vector<int> b(n - 1);
    int cur = 1;
    for (int i = 1; i < n; i++) {
      b[i - 1] = (cur * a[i] + a[i - 1]) % mod;
      if (b[i - 1] < 0) b[i] += mod;
      cur *= -1;
    }
    return solve(b);
  }
  int sa = 0, sb = 0, p = (n - 2) / 2;
  for (int i = 0; i < n; i++) {
    int val = (1ll * fact[p] * rfact[p - (i / 2)]) % mod;
    val = (1ll * val * rfact[i / 2]) % mod;
    if ((i & 1) == 0) {
      sa = (sa + (1ll * val * a[i])) % mod;
    } else {
      sb = (sb + (1ll * val * a[i])) % mod;
    }
  }
  int cur;
  if ((n / 2) & 1) {
    cur = 1;
  } else {
    cur = -1;
  }
  return ((sa + cur * sb) % mod + mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fact[0] = 1;
  rfact[0] = 1;
  for (int i = 1; i < 200005; i++) {
    fact[i] = (1ll * fact[i - 1] * i) % mod;
    rfact[i] = powmod(fact[i], mod - 2) % mod;
  }
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve(a) << endl;
  return 0;
}
