#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long qsm(long long a, int b) {
  a %= mod;
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return ret;
}
long long a[220000], b[220000], f[220000];
int main() {
  long long n;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]), b[i] = a[i];
  if (n == 1) {
    printf("%lld\n", a[0]);
    return 0;
  }
  if (n & 1) {
    n--;
    int o = 0;
    for (int i = 0; i < n; i++) {
      if (!o)
        b[i] = (a[i] + a[i + 1]) % mod;
      else
        b[i] = (a[i] - a[i + 1]) % mod;
      o ^= 1;
    }
  }
  f[0] = 1;
  long long m = n / 2 - 1;
  for (int i = 1; i <= m; i++) f[i] = f[i - 1] * i % mod;
  long long ans1 = 0, ans2 = 0;
  for (int i = 0; i <= m; i++) {
    ans1 = (ans1 + f[m] * qsm(f[i] * f[m - i], mod - 2) % mod * b[i * 2]) % mod;
    ans2 = (ans2 + f[m] * qsm(f[i] * f[m - i], mod - 2) % mod * b[i * 2 + 1]) %
           mod;
  }
  long long ans;
  if ((n * (n - 1) / 2) & 1)
    ans = ((ans1 + ans2) % mod + mod) % mod;
  else
    ans = ((ans1 - ans2) % mod + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}
