#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const int mod = 1e9 + 7;
int n;
int a[maxn];
int b[maxn];
int c[maxn];
int inv[maxn];
int mp(int x, int n) {
  int ret = 1;
  while (n) {
    if (n & 1) ret = 1ll * ret * x % mod;
    x = 1ll * x * x % mod;
    n >>= 1;
  }
  return ret;
}
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
}
void getC(int n) {
  int N = n / 2;
  c[1] = 1;
  c[2] = N & 1 ? 1 : mod - 1;
  for (int i = 3; i <= n; i += 2) {
    int k = ((i + 1) >> 1) - 1;
    c[i] = 1ll * c[i - 2] * inv[k] % mod * (N - k) % mod;
    c[i + 1] = (1ll * c[i] * (N & 1 ? 1 : -1) + mod) % mod;
  }
}
void getb() {
  if (n & 1)
    getC(n + 1);
  else
    getC(n);
  if (n & 1) {
    int N = (n + 1) >> 1;
    if ((N & 1) == 0) {
      b[1] = 1;
      for (int i = 2; i <= n; i++)
        b[i] = i & 1 ? (1ll * c[i] - b[i - 1] + mod) % mod
                     : (1ll * b[i - 1] - c[i] + mod) % mod;
    } else {
      for (int i = 1; i <= n; i++) b[i] = i & 1 ? c[i] : 0;
    }
  } else {
    for (int i = 1; i <= n; i++) b[i] = c[i];
  }
}
void solve() {
  getb();
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = (ans + 1ll * a[i] * b[i] % mod) % mod;
  ;
  printf("%d\n", ans);
}
void init() {
  for (int i = 1; i < maxn; i++) inv[i] = mp(i, mod - 2);
}
int main() {
  init();
  read();
  solve();
  return 0;
}
