#include <bits/stdc++.h>
const long long mod = 1000000007;
const int N = 200050;
long long fac[N], rev[N];
long long pow_mod(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ans = ans * a % mod;
  return ans;
}
inline long long C(int n, int m) {
  return fac[n] * rev[n - m] % mod * rev[m] % mod;
}
int main() {
  int n, x;
  long long ans = 0;
  scanf("%d", &n);
  int t = (n - 1) / 2;
  fac[0] = 1;
  for (int i = 1; i <= t; ++i) fac[i] = fac[i - 1] * i % mod;
  rev[t] = pow_mod(fac[t], mod - 2);
  for (int i = t; i; --i) rev[i - 1] = rev[i] * i % mod;
  if (n & 1) {
    if (n & 2) {
      int y = 0, l = 1;
      scanf("%d", &y);
      --t;
      for (int i = 0; i < n - 1; ++i) {
        scanf("%d", &x);
        ans = (ans + (y + x * l) % mod * C(t, i >> 1) % mod) % mod;
        l *= -1;
        y = x;
      }
    } else {
      for (int i = 0; i < n; ++i) {
        scanf("%d", &x);
        if (~i & 1) ans = (ans + x * C(t, i >> 1) % mod) % mod;
      }
    }
  } else if (n % 4 == 0) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x);
      if (i & 1)
        ans = (ans - x * C(t, i >> 1) % mod) % mod;
      else
        ans = (ans + x * C(t, i >> 1) % mod) % mod;
    }
  } else {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x);
      ans = (ans + x * C(t, i >> 1) % mod) % mod;
    }
  }
  printf("%I64d\n", (ans + mod) % mod);
  return 0;
}
