#include <bits/stdc++.h>
using namespace std;
long long md = 1e9 + 7;
long long fact[200005];
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  return (pw((a * a) % md, b / 2) * (b % 2 ? a : 1)) % md;
}
long long inv(long long x) { return pw(x, 1e9 + 5); }
long long choose(long long a, long long b) {
  return (((fact[a] * inv(fact[b])) % md) * inv(fact[a - b])) % md;
}
long long A[200005];
bool flip;
int n;
long long ans;
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(0);
  fact[0] = 1;
  for (int i = 1; i <= 200005; i++) fact[i] = (fact[i - 1] * i) % md;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  while (n % 4 != 1) {
    for (int i = 0; i < n - 1; i++) {
      if (!flip)
        A[i] = A[i] + A[i + 1];
      else
        A[i] = A[i] - A[i + 1];
      flip ^= 1;
    }
    n--;
  }
  n--;
  n /= 2;
  for (int i = 0; i < n + 1; i++) {
    ans = (ans + A[i * 2] * choose(n, i)) % md;
  }
  ans = (ans + md) % md;
  cout << ans << endl;
}
