#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int jyb = 1e9 + 7;
int n;
int a[maxn];
int c[maxn];
int p[4][maxn];
int op[maxn];
int power(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = (long long)a * a % jyb)
    if (b & 1) res = (long long)res * a % jyb;
  return res;
}
int inv(int a) { return power(a, jyb - 2); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  c[0] = 1;
  int k = (n - 1) / 4, pp = (n - 1) % 4;
  int nn = k * 2;
  for (int i = 1; i <= nn; i++)
    c[i] = (long long)c[i - 1] * (nn + 1 - i) % jyb * inv(i) % jyb;
  if (pp >= 0) {
    for (int i = 1; i <= n - pp; i++)
      if (i & 1)
        p[0][i] = c[(i - 1) / 2];
      else
        p[0][i] = 0;
  }
  if (pp >= 1) {
    for (int i = 1; i <= n - pp + 1; i++)
      if (i & 1)
        p[1][i] = p[0][i];
      else
        p[1][i] = p[0][i - 1];
  }
  if (pp >= 2) {
    for (int i = 1; i <= n - pp + 2; i++)
      if (i & 1)
        p[2][i] = p[1][i] - p[1][i - 1];
      else
        p[2][i] = p[1][i] + p[1][i - 1];
  }
  if (pp >= 3) {
    for (int i = 1; i <= n; i++)
      if (i & 1)
        p[3][i] = p[2][i] + p[2][i - 1];
      else
        p[3][i] = p[2][i - 1] - p[2][i];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + 1ll * a[i] * p[pp][i] % jyb + jyb) % jyb;
  }
  printf("%I64d\n", ans);
  return 0;
}
