#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
const int mod = 1000000007;
int qpow(int a, int n) {
  if (n == 0) return 1;
  int b = qpow(a, n / 2);
  b = 1LL * b * b % mod;
  if (n & 1) b = 1LL * a * b % mod;
  return b;
}
int inv(int x) { return qpow(x, mod - 2); }
int n;
int a[N], b[4][N];
inline int f(int x, int y, int s) {
  int r = s & 1 ? x - y : x + y;
  if (r < 0) r += mod;
  if (r >= mod) r -= mod;
  return r;
}
int go() {
  int m = n, s = 0;
  for (int i = (0); i <= (int(n) - 1); ++i) b[0][i] = a[i];
  int it = 1;
  while (m % 4 != 1) {
    m--;
    for (int i = (0); i <= (int(m) - 1); ++i) {
      b[it][i] = f(b[it - 1][i], b[it - 1][i + 1], s + i);
    }
    s = (s + m) % 2;
    it++;
  }
  for (int i = (0); i <= (int(m) - 1); ++i) a[i] = b[it - 1][i];
  return m;
}
void test() {
  scanf("%d", &n);
  for (int i = (0); i <= (int(n) - 1); ++i) scanf("%d", &a[i]);
  n = go();
  int m = n / 2;
  int cur = 1;
  int res = 0;
  printf("\n");
  for (int i = 0; 2 * i < n; i++) {
    res = (1LL * cur * a[2 * i] + res) % mod;
    cur = 1LL * cur * (m - i) % mod;
    cur = 1LL * cur * inv(i + 1) % mod;
  }
  printf("%d\n", res);
}
int main() {
  int ttn = 1;
  while (ttn--) test();
  return 0;
}
