#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const long long mod = 1000000007;
long long fac[maxn], rev[maxn];
long long mul[maxn], tmp[maxn];
long long qpow(long long a, long long b) {
  long long ret = 1LL, t = a;
  while (b) {
    if (b & 1) ret = (ret * t) % mod;
    t = (t * t) % mod;
    b >>= 1;
  }
  return ret;
}
long long calc(int a, int b) {
  long long ret = (fac[a] * rev[b]) % mod;
  ret = (ret * rev[a - b]) % mod;
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) fac[i] = (fac[i - 1] * (long long)i) % mod;
  for (int i = 0; i < maxn; i++) rev[i] = qpow(fac[i], mod - 2);
  if (n % 4 == 1) {
    int t = (n / 4) * 2;
    for (int i = 1; i <= n; i++) mul[i] = (i % 2 == 0) ? 0 : (calc(t, i / 2));
  }
  if (n % 4 == 2) {
    int t = (n / 4) * 2;
    for (int i = 1; i <= n; i++)
      mul[i] = (i % 2 == 1) ? (calc(t, (i - 1) / 2)) : mul[i - 1];
  }
  if (n % 4 == 3) {
    int t = (n / 4) * 2;
    for (int i = 1; i <= n; i++)
      tmp[i] = (i % 2 == 1) ? (calc(t, (i - 1) / 2)) : tmp[i - 1];
    for (int i = 1; i <= n; i++)
      mul[i] = (i % 2 == 0) ? (tmp[i] + tmp[i - 1]) : (tmp[i] - tmp[i - 1]);
  }
  if (n % 4 == 0) {
    int t = (n - 2) / 2;
    for (int i = 1; i <= n; i++)
      mul[i] = (i % 2 == 1) ? (calc(t, (i - 1) / 2)) : (-mul[i - 1]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    ans = (ans + x * mul[i]) % mod;
  }
  if (ans < 0) ans += ((-ans) / mod + 1) * mod;
  printf("%lld\n", ans);
  return 0;
}
