#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10, MOD = 1e9 + 7;
long long n, a[N], f[N], ans;
void init_factorial(long long n) {
  f[0] = 1;
  for (int i = 1; i <= n; i++) f[i] = (f[i - 1] * i) % MOD;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
long long C(long long k, long long n) {
  return f[n] * power(f[k] * f[n - k] % MOD, MOD - 2) % MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[1];
    return 0;
  }
  if (n & 1) {
    for (int i = 1; i < n; i++)
      if (i & 1)
        a[i] = (a[i] + a[i + 1]) % MOD;
      else
        a[i] = (a[i] - a[i + 1] + MOD) % MOD;
    n--;
  }
  init_factorial(n);
  if ((n / 2) & 1)
    for (int i = 1; i < n; i += 2)
      ans = (ans + (a[i] + a[i + 1]) % MOD * C((i - 1) / 2, n / 2 - 1) % MOD) %
            MOD;
  else
    for (int i = 1; i < n; i += 2)
      ans = (ans +
             (a[i] - a[i + 1] + MOD) % MOD * C((i - 1) / 2, n / 2 - 1) % MOD) %
            MOD;
  cout << ans;
  return 0;
}
