#include <bits/stdc++.h>
using namespace std;
int i, j, k, m, n, s, t;
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int fac[1001000], inv[10010000], b[1001000], c[1001000], ans;
void add(int &x, int y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
}
int C(int n, int m) {
  return (long long)fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int main() {
  n = read();
  fac[0] = 1;
  inv[1] = 1;
  for (i = 1; i <= n; i++) fac[i] = (long long)fac[i - 1] * i % 1000000007;
  for (i = 2; i <= n; i++)
    inv[i] = (long long)(1000000007 - 1000000007 / i) * inv[1000000007 % i] %
             1000000007;
  inv[0] = 1;
  for (i = 2; i <= n; i++) inv[i] = (long long)inv[i - 1] * inv[i] % 1000000007;
  m = n / 2 - 1;
  for (i = 0; i <= m; i++) b[i] = C(m, i);
  b[0] = 1;
  for (i = 0; i < n; i++) c[i] = b[i >> 1];
  if (m & 1)
    for (i = 1; i < n; i += 2) c[i] = -c[i];
  if (n & 1) {
    for (i = n - 1; i; i--)
      if (i & 1)
        c[i] = c[i] + c[i - 1];
      else
        c[i] = c[i] - c[i - 1];
  }
  for (i = 0; i < n; i++) add(ans, (long long)read() * c[i] % 1000000007);
  printf("%d\n", ans);
}
