#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1 << 30;
const double eps = 1e-13;
const long long MAXN = 400009;
long long f[MAXN], invf[MAXN];
long long d[200009];
long long expo(long long a, long long b) {
  if (b == 0) return 1;
  long long h = expo(a, b / 2);
  h = (h * h) % MOD;
  if (b % 2) h = (h * a) % MOD;
  return h;
}
long long choose(int a, int b) {
  return ((f[a] * invf[b]) % MOD * invf[a - b]) % MOD;
}
int main() {
  f[0] = invf[0] = 1;
  for (int i = (1); i < (MAXN); ++i) {
    f[i] = (f[i - 1] * i) % MOD;
    invf[i] = expo(f[i], MOD - 2);
  }
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%I64d", &d[i]);
  if (n == 1) {
    printf("%I64d", d[0]);
    return 0;
  }
  if (n == 2) {
    printf("%I64d", (d[0] + d[1]) % MOD);
    return 0;
  }
  int n2 = n;
  if (n % 2) {
    n2 ^= 1;
    long long nd[200009];
    for (int i = 0; i < (n2); ++i) {
      if (i % 2 == 0)
        nd[i] = (d[i] + d[i + 1]) % MOD;
      else
        nd[i] = (d[i] - d[i + 1] + MOD) % MOD;
    }
    swap(nd, d);
  }
  long long left = 0, right = 0;
  int h = n2 / 2 - 1;
  for (int i = 0; 2 * i < n2; i++) {
    left = (left + choose(h, i) * d[i * 2]) % MOD;
    right = (right + choose(h, i) * d[i * 2 + 1]) % MOD;
  }
  long long ans = 0;
  if ((((long long)n * (n - 1)) / 2) % 2) {
    ans = (left + right) % MOD;
  } else {
    ans = (left - right + MOD) % MOD;
  }
  printf("%I64d", (ans % MOD + MOD) % MOD);
}
