#include <bits/stdc++.h>
using namespace std;
long long a[202020], k = 1, ans, mod = 1e9 + 7;
long long quick_power(long long a, long long b = mod - 2) {
  long long s = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) s = s * a % mod;
  return s;
}
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (; n % 4 != 1;)
    for (n--, i = 1; i <= n; i++)
      a[i] = (a[i] + k * a[i + 1] + mod) % mod, k *= -1;
  for (k = 1, ans = a[1], i = 1; i <= n / 2; i++)
    k = k * (n / 2 - i + 1) % mod * quick_power(i) % mod,
    ans = (ans + k * a[i * 2 + 1]) % mod;
  printf("%lld", ans);
}
