#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
long long f[N], fv[N];
long long a[N];
long long FastPower(long long a, long long x) {
  long long res = 1;
  while (x) {
    if (x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}
void init() {
  f[0] = 1;
  for (long long i = 1; i < N; i++) f[i] = (f[i - 1] * i) % mod;
  fv[N - 1] = FastPower(f[N - 1], mod - 2);
  for (long long i = N - 1; i > 0; i--) fv[i - 1] = (fv[i] * i) % mod;
}
long long CC(long long a, long long b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return f[a] * fv[b] % mod * fv[a - b] % mod;
}
int main() {
  int n;
  int op;
  long long ans, temp;
  init();
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    if (n == 1)
      printf("%lld\n", a[n]);
    else if (n == 2)
      printf("%lld\n", (a[1] + a[2]) % mod);
    else {
      if (n % 2) {
        for (int i = 1; i < n; i++) {
          if (i % 2 == 0) {
            a[i] = (a[i] - a[i + 1]) % mod;
            if (a[i] < 0) a[i] = (a[i] % mod + mod);
          } else
            a[i] = (a[i] + a[i + 1]) % mod;
        }
        n--;
      }
      if (n % 4 == 0)
        op = -1;
      else
        op = 1;
      ans = 0;
      for (int i = 1; i <= n; i += 2) {
        temp = CC(n / 2 - 1, i / 2);
        ans = (temp * (a[i] + op * a[i + 1]) % mod + ans) % mod;
      }
      ans = (ans + mod) % mod;
      printf("%lld\n", ans);
    }
  }
}
