#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
int a[maxn];
int b[maxn];
const long long MOD = 1e9 + 7;
long long fact[maxn];
long long inv[maxn];
long long rev[maxn];
long long C(int n, int k) { return fact[n] * inv[n - k] % MOD * inv[k] % MOD; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  fact[0] = 1;
  fact[1] = 1;
  inv[0] = 1;
  inv[1] = 1;
  rev[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
    rev[i] = (-(MOD / i) * rev[MOD % i]) % MOD;
    inv[i] = inv[i - 1] * rev[i] % MOD;
  }
  if (n % 4 == 0) {
    int N = (n - 2) / 2;
    long long ans = 0;
    for (int i = 0; i <= N; ++i) {
      ans += 1ll * a[2 * i + 1] * C(N, i);
      ans += 1ll * (-a[2 * i + 2]) * C(N, i);
      ans %= MOD;
    }
    cout << (ans + MOD) % MOD;
  } else if (n % 4 == 1) {
    int op = 1;
    for (int i = 1; i < n; ++i) {
      if (op)
        b[i] = a[i + 1] + a[i];
      else
        b[i] = a[i] - a[i + 1];
      op = !op;
    }
    n--;
    for (int i = 1; i <= n; ++i) a[i] = b[i];
    int N = (n - 2) / 2;
    long long ans = 0;
    for (int i = 0; i <= N; ++i) {
      ans += 1ll * a[2 * i + 1] * C(N, i);
      ans += 1ll * (-a[2 * i + 2]) * C(N, i);
      ans %= MOD;
    }
    cout << (ans + MOD) % MOD;
  } else if (n % 4 == 2) {
    int N = (n - 2) / 2;
    long long ans = 0;
    for (int i = 0; i <= N; ++i) {
      ans += 1ll * a[2 * i + 1] * C(N, i);
      ans += 1ll * a[2 * i + 2] * C(N, i);
      ans %= MOD;
    }
    cout << (ans + MOD) % MOD;
  } else {
    int op = 1;
    for (int i = 1; i < n; ++i) {
      if (op)
        b[i] = a[i + 1] + a[i];
      else
        b[i] = a[i] - a[i + 1];
      op = !op;
    }
    n--;
    for (int i = 1; i <= n; ++i) a[i] = b[i];
    int N = (n - 2) / 2;
    long long ans = 0;
    for (int i = 0; i <= N; ++i) {
      ans += 1ll * a[2 * i + 1] * C(N, i);
      ans += 1ll * a[2 * i + 2] * C(N, i);
      ans %= MOD;
    }
    cout << (ans + MOD) % MOD;
  }
}
