#include <bits/stdc++.h>
const int MAXN = 200005;
const int MOD = 1000000007;
long long fact[MAXN];
void prepare() {
  fact[0] = 1;
  for (int i = 1; i < MAXN; i++) fact[i] = fact[i - 1] * i % MOD;
}
long long pow(long long a, long long n) {
  long long res = 1;
  for (; n; n >>= 1, a = a * a % MOD)
    if (n & 1) res = res * a % MOD;
  return res;
}
long long inv(long long x) { return pow(x, MOD - 2); }
long long combi(int n, int m) {
  return fact[n] * inv(fact[m]) % MOD * inv(fact[n - m]) % MOD;
}
int main() {
  prepare();
  int n;
  scanf("%d", &n);
  static int a[MAXN];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (n % 4 == 0) {
    int k = (n - 1) / 2;
    long long ans = 0;
    for (int i = 0; i <= k; i++)
      (ans += combi(k, i) * ((a[2 * i] - a[2 * i + 1] + MOD) % MOD) % MOD) %=
          MOD;
    printf("%I64d\n", ans);
  } else if (n % 4 == 1) {
    int k = n / 2;
    long long ans = 0;
    for (int i = 0; i <= k; i++) (ans += combi(k, i) * a[2 * i] % MOD) %= MOD;
    printf("%I64d\n", ans);
  } else if (n % 4 == 2) {
    int k = (n - 1) / 2;
    long long ans = 0;
    for (int i = 0; i <= k; i++)
      (ans += combi(k, i) * ((a[2 * i] + a[2 * i + 1]) % MOD) % MOD) %= MOD;
    printf("%I64d\n", ans);
  } else {
    int k = (n - 2) / 2;
    long long ans = 0;
    for (int i = 0; i <= k; i++) {
      (ans += combi(k, i) * ((a[2 * i] + a[2 * i + 1]) % MOD) % MOD) %= MOD;
      (ans +=
       combi(k, i) * ((a[2 * i + 1] - a[2 * i + 2] + MOD) % MOD) % MOD) %= MOD;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
