#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9) + 7;
const int maxn = 200010;
int n;
long long a[maxn];
long long fact[maxn];
long long ans;
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", &a[i]);
}
long long exp(long long x) {
  long long s = 1, times = mod - 2;
  while (times) {
    if (times & 1) s = s * x % mod;
    x = x * x % mod;
    times >>= 1;
  }
  return s;
}
long long calc(int x, int y) {
  return (fact[x] * exp(fact[y] * fact[x - y] % mod) % mod);
}
void solve() {
  if (n == 1) {
    ans = a[1];
    return;
  }
  if (n & 1) {
    for (int i = 1; i < n; ++i) a[i] += ((i & 1) ? a[i + 1] : -a[i + 1]);
    --n;
  }
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % mod;
  ans = 0;
  if (n % 4 == 0) {
    for (int i = 1; i <= n; ++i) {
      long long tmp = calc(n / 2 - 1, (i - 1) / 2) * a[i] % mod;
      if (i & 1)
        ans = (ans + tmp) % mod;
      else
        ans = (ans - tmp + mod) % mod;
    }
  } else {
    for (int i = 1; i <= n; ++i)
      ans = (ans + calc(n / 2 - 1, (i - 1) / 2) * a[i] % mod) % mod;
  }
}
int main() {
  read();
  solve();
  while (ans < 0) ans += mod;
  printf("%I64d\n", ans);
  return 0;
}
