#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
long long fact[maxn];
long long modinv[maxn];
long long power(long long A, long long M, long long P) {
  long long res = 1;
  A %= mod;
  while (M) {
    if (M & 1) res = (res * A) % mod;
    M /= 2;
    A = (A * A) % mod;
  }
  return res % mod;
}
long long nCr(long long N, long long R) {
  return (fact[N] * ((modinv[N - R] * modinv[R]) % mod)) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  fact[0] = 1;
  for (int i = 1; i < maxn; i++) fact[i] = (fact[i - 1] * i) % mod;
  for (int i = 1; i < maxn; i++) modinv[i] = power(fact[i], mod - 2, mod);
  modinv[0] = modinv[1];
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long long ans = 0;
  if (N % 4 == 0) {
    long long sup = N / 2 - 1;
    for (int i = 0; i < N; i++) {
      ans += A[i] * nCr(sup, i / 2) * (i % 2 == 0 ? 1 : -1);
      ans %= mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
  } else if (N % 4 == 1) {
    long long sup = N / 2;
    for (int i = 0; i < N; i += 2) {
      ans += A[i] * nCr(sup, i / 2);
      ans %= mod;
    }
    if (ans < 0) ans += mod;
    ans %= mod;
    cout << ans << endl;
  } else if (N % 4 == 2) {
    long long sup = N / 2 - 1;
    for (int i = 0; i < N; i++) {
      ans += A[i] * nCr(sup, i / 2);
      ans %= mod;
    }
    if (ans < 0) ans += mod;
    ans %= mod;
    cout << ans << endl;
  } else {
    long long sup = (N - 1) / 2 - 1;
    for (int i = 1; i < N; i += 2) {
      ans += 2 * A[i] * nCr(sup, i / 2);
      ans %= mod;
    }
    ans += A[0];
    ans %= mod;
    for (int i = 2; i < N; i += 2) {
      ans += A[i] * (nCr(sup, i / 2) - nCr(sup, i / 2 - 1));
      ans %= mod;
    }
    if (ans < 0) ans += mod;
    ans %= mod;
    cout << ans << endl;
  }
  return 0;
}
