#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long a[1000000];
long long Fac[1000000], Inv[1000000], inv[1000000];
void ini() {
  Fac[0] = Inv[0] = Fac[1] = Inv[1] = inv[1] = 1;
  for (int i = 2; i < 1000000; i++) {
    Fac[i] = Fac[i - 1] * i % mod;
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    Inv[i] = Inv[i - 1] * inv[i] % mod;
  }
}
long long C(int n, int m) { return Fac[n] * Inv[m] % mod * Inv[n - m] % mod; }
int op(int n, int s) {
  if (n % 4 == 1) return n;
  for (int i = 1; i < n; i++) {
    a[i] = a[i] + s * a[i + 1];
    a[i] %= mod;
    s *= -1;
  }
  return op(n - 1, s);
}
int solve(int n, int s) {
  if (n == 1) return (a[1] + mod) % mod;
  for (int i = 1; i < n; i++) {
    a[i] = a[i] + s * a[i + 1];
    a[i] %= mod;
    s *= -1;
  }
  return (solve(n - 1, s) + mod) % mod;
}
int main() {
  ini();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  if (n < 100) {
    printf("%d", solve(n, 1));
  } else {
    while (n % 4 != 1) {
      n = op(n, 1);
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 2) {
        res += a[i] * C(n / 2, i / 2) % mod;
        res %= mod;
      }
    }
    cout << (res + mod) % mod;
  }
  return 0;
}
