#include <bits/stdc++.h>
long long ar[1000010], fact[1000010];
long long expo(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1LL) res = (res * x) % 1000000007;
    x = (x * x) % 1000000007;
    n >>= 1LL;
  }
  return (res % 1000000007);
}
long long binomial(int n, int k) {
  long long x = fact[n];
  long long y = (fact[k] * fact[n - k]) % 1000000007;
  long long res = (x * expo(y, 1000000007 - 2)) % 1000000007;
  return res;
}
long long solve(int n, long long ar[1000010]) {
  if (n == 1) return ar[0] % 1000000007;
  int i, j, k;
  long long x, y, z, res = 0;
  if ((n % 4) == 0) {
    for (i = 0; i < n; i++) {
      x = binomial(n / 2 - 1, i / 2) * ar[i] % 1000000007;
      if (i % 2 == 1)
        res = (res - x + 1000000007) % 1000000007;
      else
        res = (res + x) % 1000000007;
    }
  }
  if ((n % 4) == 1) {
    for (i = 0; i < n; i++) {
      if (i % 2 == 0) res = (res + binomial(n / 2, i / 2) * ar[i]) % 1000000007;
    }
  }
  if ((n % 4) == 2) {
    for (i = 0; i < n; i++) {
      res = (res + binomial(n / 2 - 1, i / 2) * ar[i]) % 1000000007;
    }
  }
  if ((n % 4) == 3) {
    for (i = 0; i < n; i++) {
      if ((i % 2) == 1) {
        x = binomial(n / 2 - 1, i / 2) * 2 % 1000000007;
      } else {
        x = binomial(n / 2 - 1, i / 2);
        if (i)
          x = (x - binomial(n / 2 - 1, i / 2 - 1) + 1000000007) % 1000000007;
        if ((2 * i) > n) x = x - 1000000007;
      }
      res = (res + ((x * ar[i]) % 1000000007) + 1000000007) % 1000000007;
    }
  }
  return res % 1000000007;
}
int main() {
  int n, i, j, k;
  for (i = 1, fact[0] = 1; i < 1000010; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%lld", &ar[i]);
    printf("%lld\n", solve(n, ar));
  }
  return 0;
}
