#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int a[200010];
int fac[200010], inv[200010];
inline void init() {
  fac[1] = 1;
  for (int i = (2); i <= (200000); i++)
    fac[i] = 1ll * fac[i - 1] * i % 1000000007;
  inv[0] = inv[1] = 1;
  for (int i = (2); i <= (200000); i++)
    inv[i] =
        1ll * (1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007;
  for (int i = (2); i <= (200000); i++)
    inv[i] = 1ll * inv[i - 1] * inv[i] % 1000000007;
}
inline int C(int n, int m) {
  if (n == 0) return 1;
  return 1ll * fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int main() {
  int n = read();
  for (int i = (1); i <= (n); i++) a[i] = read();
  if (n <= 2) {
    printf("%d\n", (a[2] + a[1]) % 1000000007);
    return 0;
  }
  if (n & 1) {
    int t = 1;
    for (int i = (1); i <= (n - 1); i++) {
      a[i] = (a[i] + t * a[i + 1]) % 1000000007;
      t = -t;
    }
    n--;
  }
  init();
  long long ans = 0, t = -1;
  if (n % 4) t = 1;
  for (int i = 1; i <= n; i += 2) {
    long long p = C(n / 2 - 1, i / 2);
    ans += 1ll * (a[i] + t * a[i + 1]) * p % 1000000007;
    ans %= 1000000007;
  }
  printf("%lld\n", (ans + 1000000007) % 1000000007);
  return 0;
}
