#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 2e5 + 5;
long long pw(long long a, long long p = M - 2, long long MOD = M) {
  long long result = 1;
  while (p > 0) {
    if (p & 1) result = a * result % MOD;
    a = a * a % MOD;
    p >>= 1;
  }
  return result;
}
long long fact[N], invfact[N];
void init() {
  long long p = M;
  fact[0] = 1;
  long long i;
  for (i = 1; i < N; i++) {
    fact[i] = i * fact[i - 1] % p;
  }
  i--;
  invfact[i] = pw(fact[i], p - 2, p);
  for (i--; i >= 0; i--) {
    invfact[i] = invfact[i + 1] * (i + 1) % p;
  }
}
long long ncr(long long n, long long r) {
  if (r > n || n < 0 || r < 0) return 0;
  return fact[n] * invfact[r] % M * invfact[n - r] % M;
}
long long n;
long long tmp;
long long calc(long long id, vector<long long> &a) {
  long long ret = 0;
  long long cnt = 0;
  while (id < n / 2 * 2) {
    ret += ncr(tmp, cnt) * a[id] % M;
    ret %= M;
    id += 2;
    cnt++;
  }
  return ret;
}
void solve() {
  cin >> n;
  vector<long long> a(n);
  for (long long &x : a) {
    cin >> x;
  }
  if (n == 1) {
    cout << a[0];
    return;
  }
  if (n % 2) {
    vector<long long> b;
    for (long long i = 0; i < n - 1; i++) {
      if (i % 2 == 0)
        b.push_back(a[i] + a[i + 1]);
      else
        b.push_back(a[i] - a[i + 1]);
      b.back() += M;
      b.back() %= M;
    }
    a = b;
  }
  tmp = (n - 2) / 2;
  long long x = calc(0, a), y = calc(1, a);
  if ((n * (n - 1) / 2) % 2 == 0) {
    cout << (x - y + M) % M;
  } else {
    cout << (x + y) % M;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  long long t = 1;
  while (t--) solve();
  return 0;
}
