#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200005], fact[200005], ifact[200005];
long long modpow(long long b, long long e) {
  long long an = 1;
  for (; e; e >>= 1) {
    if (e & 1) an = (an * b) % 1000000007;
    b = (b * b) % 1000000007;
  }
  return an;
}
long long inverse(long long a) { return modpow(a, 1000000007 - 2); }
long long C(long long k, long long n) {
  return fact[n] * ifact[k] % 1000000007 * ifact[n - k] % 1000000007;
}
int main() {
  scanf("%d", &n);
  fact[0] = 1, ifact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
    ifact[i] = modpow(fact[i], 1000000007 - 2);
  }
  if (n % 4 == 0) {
    long long an = 0;
    for (int i = 0; i < n; i++) {
      long long x;
      scanf("%lld", &x);
      if (i & 1)
        an = (an - x * C(i >> 1, (n - 2) >> 1) % 1000000007) % 1000000007;
      else
        an = (an + x * C(i >> 1, (n - 2) / 2) % 1000000007) % 1000000007;
    }
    printf("%lld", (an % 1000000007 + 1000000007) % 1000000007);
  } else if (n % 4 == 1) {
    long long an = 0;
    for (int i = 0; i < n; i++) {
      long long x;
      scanf("%lld", &x);
      if (i & 1) continue;
      an = (an + x * C(i >> 1, (n - 1) >> 1) % 1000000007) % 1000000007;
    }
    printf("%lld", (an % 1000000007 + 1000000007) % 1000000007);
  } else if (n % 4 == 2) {
    long long an = 0;
    for (int i = 0; i < n; i++) {
      long long x;
      scanf("%lld", &x);
      an = (an + x * C(i >> 1, (n - 2) >> 1) % 1000000007) % 1000000007;
    }
    printf("%lld", (an % 1000000007 + 1000000007) % 1000000007);
  } else {
    long long an = 0;
    int y = 0, l = 1;
    int x;
    scanf("%d", &y);
    int t = ((n - 1) >> 1) - 1;
    for (int i = 0; i < n - 1; ++i) {
      scanf("%d", &x);
      an = (an + (y + x * l) % 1000000007 * C(i >> 1, t) % 1000000007) %
           1000000007;
      l *= -1;
      y = x;
    }
    printf("%lld", (an % 1000000007 + 1000000007) % 1000000007);
  }
  return 0;
}
