#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int mod = 1e9 + 7;
int n, a[N], deal[N];
long long fac[N] = {1, 1}, inv[N] = {0, 1}, f[N] = {1, 1};
void init() {
  for (int i = 2; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
    f[i] = (mod - mod / i) * f[mod % i] % mod;
    inv[i] = inv[i - 1] * f[i] % mod;
  }
}
long long C(long long n, long long i) {
  if (i == 0 || i == n) return 1;
  return fac[n] * inv[n - i] % mod * inv[i] % mod;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (n <= 2) {
    printf("%d\n", (a[1] + a[2]) % mod);
    return 0;
  }
  if (n % 2) {
    for (int i = 2; i <= n; i++)
      (deal[i - 1] = a[i - 1] + (i % 2 ? -1 : 1) * a[i]) %= mod;
    n--;
  } else {
    for (int i = 1; i <= n; i++) deal[i] = a[i];
  }
  long long ans = 0, tmpC;
  int ope = (n % 4 == 0 ? -1 : 1);
  for (int i = 1; i <= n; i += 2) {
    tmpC = C(n / 2 - 1, i / 2);
    (ans += tmpC * (deal[i] + ope * deal[i + 1]) % mod) %= mod;
  }
  ans = (ans % mod + mod) % mod;
  printf("%d\n", ans % mod);
}
