#include <bits/stdc++.h>
using namespace std;
const int N = 200007;
const long long MOD = (long long)1e9 + 7;
int n;
long long arr[2][N];
long long *a = arr[0], *b = arr[1];
long long fac[N];
void init() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = (fac[i - 1] * i) % MOD;
  }
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long d = a;
  if (b == 0) {
    x = 1, y = 0;
  } else {
    extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return d;
}
long long mod_inverse(long long a) {
  long long x, y;
  extgcd(a, MOD, x, y);
  return (MOD + x % MOD) % MOD;
}
long long comb(long long m, long long n) {
  if (m < n) return 1;
  return ((fac[m] * mod_inverse(fac[m - n])) % MOD * mod_inverse(fac[n])) % MOD;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", a + i);
  }
  if (n < 2) {
    printf("%d\n", a[0]);
    return 0;
  }
  bool op = true;
  while ((n & 1) || !op) {
    for (int i = 0; i < n - 1; i++) {
      if (op)
        b[i] = a[i] + a[i + 1];
      else
        b[i] = a[i] - a[i + 1];
      op = !op;
    }
    n--;
    swap(a, b);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long res = a[i] * comb(n / 2 - 1, i / 2);
    if (n % 4 == 0 && i % 2 != 0) res = -res;
    ans = (ans + res) % MOD;
  }
  printf("%I64d\n", (MOD + ans) % MOD);
  return 0;
}
