#include <bits/stdc++.h>
const long long oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
int o(int x) { return x % _p; }
long long o(long long x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
using namespace std;
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
long long a[200005], c[10][200005], inv[200005], ans = 0;
int n, k;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  if (n == 1) return 0 * printf("%I64d\n", a[1]);
  if (n == 2) return 0 * printf("%I64d\n", o(a[1] + a[2] + _p));
  if (n == 3) return 0 * printf("%I64d\n", o(a[1] - a[3] + 2 * a[2] + _p));
  if (n == 4) return 0 * printf("%I64d\n", o(a[1] + a[3] - a[2] - a[4] + _p));
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n + 2; i++)
    inv[i] = o((long long)(_p - _p / i) * inv[_p % i]);
  k = (n - 1) / 4;
  int N = n - (4 * k + 1);
  k *= 2;
  c[0][0] = 1;
  for (int i = 1; i <= k; i++)
    c[0][i] = o(o(c[0][i - 1] * (k - i + 1)) * inv[i]);
  for (int i = 2 * k + 1; i >= 0; i--) c[0][i] = (i & 1) * c[0][i / 2];
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= 2 * k + i + 1; j++)
      c[i][j] = o((1 - 2 * (i & 1 ^ 1) * (j & 1)) * c[i - 1][j - 1] +
                  (1 - 2 * (i & 1) * (j & 1 ^ 1)) * c[i - 1][j]);
  for (int i = 1; i <= n; i++) ans = o(ans + o(c[N][i] * a[i]));
  ans = o(ans + _p) % _p;
  printf("%I64d\n", ans);
  return 0;
}
