#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
int64_t n, type = 0, res = 0, a[200005], fac[200005];
int64_t Mul(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t tmp = Mul(n, k / 2);
  if (k % 2 == 0) return tmp * tmp % mod;
  return tmp * tmp % mod * n % mod;
}
int64_t C(int64_t n, int64_t k) {
  int64_t A = fac[n];
  int64_t B = fac[k] * fac[n - k] % mod;
  return A * Mul(B, mod - 2) % mod;
}
void Process1() {
  for (int i = 1; i <= n; i += 2) {
    res = (res + a[i] * C(n / 2 - 1, i / 2) + mod * mod) % mod;
    res = (res - a[i + 1] * C(n / 2 - 1, i / 2) + mod * mod) % mod;
  }
  cout << res;
  exit(0);
}
void Process2() {
  for (int i = 1; i <= n; i += 2)
    res = (res + a[i] * C(n / 2 - 1, i / 2) + mod * mod) % mod;
  for (int i = 2; i <= n; i += 2)
    res = (res + a[i] * C(n / 2 - 1, i / 2 - 1) + mod * mod) % mod;
  cout << res;
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  fac[0] = 1;
  for (int64_t i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  for (int i = 1; i <= n; i++) cin >> a[i];
  while (n > 1) {
    if (type == 0) {
      if (n % 4 == 0) Process1();
      if (n % 4 == 2) Process2();
    }
    for (int i = 1; i < n; i++) {
      if (type == 0)
        a[i] = (a[i] + a[i + 1] + 2 * mod) % mod;
      else
        a[i] = (a[i] - a[i + 1] + 2 * mod) % mod;
      type = 1 - type;
    }
    n--;
  }
  cout << a[1];
}
