#include <bits/stdc++.h>
using namespace std;
struct P {
  int x, y, z;
  bool operator<(const P &a) const { return x > a.x; }
};
vector<P> v[1];
int a, c, i, b, n, m, k, d;
int o[223111];
int l[223311];
int j[11];
long long e[11];
int dx[10] = {-1, 0, 1, 0, 1, 1, -1, -1}, dy[10] = {0, 1, 0, -1, 1, -1, 1, -1},
    dz[10] = {0, 0, 0, 0, 1, -1};
long long x, y, mod = 1000000007, mod2 = 1000000009, mod3 = 2017;
long long z[222222];
double pi = 3.14159265;
P u[355541];
stack<int> s;
queue<int> q;
bool as(P a, P b) { return a.z < b.z; }
long long g(long long n) {
  long long x = 1;
  for (int i = mod - 2; i > 0; i /= 2, n *= n, n %= mod)
    if (i % 2) x *= n, x %= mod;
  return x;
}
long long f(int n, int m) { return z[n] * g(z[m]) % mod * g(z[n - m]) % mod; }
int main() {
  z[0] = 1;
  for (int t = 1; t <= 200000; t++) z[t] = z[t - 1] * t % mod;
  scanf("%d", &a);
  for (int t = 1; t <= a; t++) scanf("%d", &o[t]);
  if (a == 1) {
    printf("%d", o[1]);
    return 0;
  }
  if (a % 2) {
    for (int t = 1; t < a; t++)
      if (t % 2)
        l[t] = o[t] + o[t + 1];
      else
        l[t] = o[t] - o[t + 1];
    for (int t = 1; t < a; t++) o[t] = l[t];
    a--;
  }
  for (int t = 1; t <= a; t++)
    if (a % 4 == 0 && t % 2 == 0)
      x -= f(a / 2 - 1, (t - 1) / 2) * o[t] % mod, x %= mod, x += mod, x %= mod;
    else
      x += f(a / 2 - 1, (t - 1) / 2) * o[t] % mod, x %= mod, x += mod, x %= mod;
  printf("%lld", x);
}
