#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
const int MAXM = 1e6;
const long long INF = 1e15;
const long long mod = 1e9 + 7;
int n, x[MAXN], fact[MAXN];
long long frac(long long a) {
  if (a == 1) return 1;
  long long b, c, d;
  c = frac(mod % a);
  d = (mod / a) * c;
  b = (-d + ((d / mod) + 1) * mod) % mod;
  return b;
}
long long c(int n, int m) {
  if (n - m < m) m = n - m;
  long long a = fact[n];
  a = (a * frac(fact[m])) % mod;
  a = (a * frac(fact[n - m])) % mod;
  return a;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  while (n != 1 && n % 4 != 0) {
    int k = 1;
    for (int i = 1; i < n; i++) {
      x[i] = ((long long)x[i] + k * x[i + 1] + mod) % mod;
      k *= -1;
    }
    n--;
  }
  if (n == 1) {
    printf("%d\n", x[1]);
    return 0;
  }
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = ((long long)fact[i - 1] * i) % mod;
  n /= 2;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + (long long)x[i * 2 - 1] * c(n - 1, i - 1)) % mod;
    ans = (ans - (long long)x[i * 2] * c(n - 1, i - 1)) % mod;
    ans = (ans + ((ans / mod) + 1) * mod) % mod;
  }
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}
