#include <bits/stdc++.h>
using namespace std;
const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;
const int MAXN = 2e5 + 10;
bool _plus = true;
int n;
int fact[MAXN];
vector<int> v;
inline int add(int a, int b) {
  a += b;
  while (a < 0) a += MOD;
  return a % MOD;
}
inline int mul(int a, int b) { return (long long)a * b % MOD; }
inline void init() {
  fact[0] = 1;
  for (int i = 1; i < MAXN; ++i) fact[i] = mul(i, fact[i - 1]);
}
int fastpow(int b, int e) {
  int ret = 1;
  while (e > 0) {
    if (e & 1) {
      ret = mul(ret, b);
      --e;
    }
    b = mul(b, b);
    e /= 2;
  }
  return ret;
}
int inv(int x) { return fastpow(x, MOD - 2); }
int _div(int a, int b) { return mul(a, inv(b)); }
int choose(int n, int k) { return _div(fact[n], mul(fact[k], fact[n - k])); }
void next_iteration() {
  vector<int> nxt;
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    if (_plus)
      nxt.push_back(add(v[i], v[i + 1]));
    else
      nxt.push_back(add(v[i], -v[i + 1]));
    _plus = !_plus;
  }
  v = nxt;
}
int main(void) {
  init();
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  while (v.size() > 1 && !(v.size() % 2 == 0 && _plus)) next_iteration();
  if (v.size() == 1) {
    printf("%d\n", v[0]);
    return 0;
  }
  int A = 0, B = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (i & 1)
      B = add(B, mul(choose((v.size() + 1) / 2 - 1, i / 2), v[i]));
    else
      A = add(A, mul(choose(v.size() / 2 - 1, i / 2), v[i]));
  }
  if ((v.size() / 2) % 2 == 0)
    printf("%d\n", add(A, -B));
  else
    printf("%d\n", add(A, B));
  return 0;
}
