#include <bits/stdc++.h>
using namespace std;
const long long zqc = 1e9 + 7;
const int maxn = 200005;
long long qpow(long long a, long long b) {
  long long ans = 1ll;
  while (b) {
    if (b & 1) ans = (ans * a) % zqc;
    b >>= 1;
    a = (a * a) % zqc;
  }
  return ans;
}
long long inv(long long a) { return qpow(a, zqc - 2); }
int n;
long long x, fac[maxn], a[maxn];
long long comb(long long a, long long b) {
  return (fac[a] * inv(fac[b]) % zqc) * inv(fac[a - b]) % zqc;
}
long long ans;
int main() {
  scanf("%d", &n);
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % zqc;
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  if (n % 4 == 0) {
    int x = (n - 2) / 2;
    for (int i = 1, j = 0; i <= n; i += 2, j++) {
      ans = (ans + comb(x, j) * a[i]) % zqc;
      ans = (ans - comb(x, j) * a[i + 1]) % zqc;
    }
    ans = (ans % zqc + zqc) % zqc;
  }
  if (n % 4 == 1) {
    int x = (n - 1) / 2;
    for (int i = 1, j = 0; i <= n; i += 2, j++)
      ans = (ans + comb(x, j) * a[i]) % zqc;
    ans = (ans % zqc + zqc) % zqc;
  }
  if (n % 4 == 2) {
    int x = (n - 2) / 2;
    for (int i = 1, j = 0; i <= n; i += 2, j++) {
      ans = (ans + comb(x, j) * a[i]) % zqc;
      ans = (ans + comb(x, j) * a[i + 1]) % zqc;
    }
    ans = (ans % zqc + zqc) % zqc;
  }
  if (n % 4 == 3) {
    int x = (n - 3) / 2;
    ans = comb(x, 0) * a[1] % zqc;
    for (int i = 2, j = 0; i <= n; i += 2, j++) {
      ans = (ans + 2 * comb(x, j) * a[i]) % zqc;
      ans = (ans + (comb(x, j + 1) - comb(x, j)) * a[i + 1]) % zqc;
    }
    ans = (ans % zqc + zqc) % zqc;
  }
  printf("%lld\n", ans);
  return 0;
}
