#include <bits/stdc++.h>
using namespace std;
long long P = 1e9 + 7, a[200010], ans, ans1, ans2, f[200010], inv[200010],
          b[100][100];
long long sqr(long long x) { return x * x % P; }
long long poww(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) return sqr(poww(a, n / 2));
  return sqr(poww(a, n / 2)) * a % P;
}
int n, m, i;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  if (n % 4 == 1) {
    m = n / 2;
    f[0] = inv[0] = 1;
    for (i = 1; i <= m; i++) {
      f[i] = f[i - 1] * (long long)i % P;
      inv[i] = inv[i - 1] * poww(i, P - 2) % P;
    }
    ans = 0;
    for (i = 0; i <= m; i++) {
      long long now = f[m] * inv[i] % P * inv[m - i] % P;
      now = now * a[2 * i + 1] % P;
      if (now < 0) now += P;
      ans = (ans + now) % P;
    }
    printf("%I64d\n", ans);
  }
  if (n % 4 == 3) {
    if (n == 3) {
      ans = a[1] - a[3] + 2 * a[2];
      ans = (ans % P + P) % P;
      printf("%I64d\n", ans);
      return 0;
    }
    for (i = 1; i * 2 < n; i++) {
      if (i % 2 == 1)
        a[i] = (a[i] - a[n + 1 - i]) % P;
      else
        a[i] = (a[i] + a[n + 1 - i]) % P;
      if (a[i] < 0) a[i] += P;
    }
    m = n / 2;
    f[0] = inv[0] = 1;
    for (i = 1; i <= m; i++) {
      f[i] = f[i - 1] * (long long)i % P;
      inv[i] = inv[i - 1] * poww(i, P - 2) % P;
    }
    long long ans = 0;
    for (i = 0; i <= m / 2; i++) {
      long long now = f[m - 1] * inv[i] % P * inv[m - 1 - i] % P;
      now = now * a[2 * i + 2] % P;
      now = now * 2 % P;
      if (now < 0) now += P;
      ans = (ans + now) % P;
    }
    for (i = 0; i <= m / 2; i++) {
      long long now1 = f[m - 2] * inv[i] % P * inv[m - 2 - i] % P;
      long long now2 = 0;
      if (i >= 2) now2 = f[m - 2] * inv[i - 2] % P * inv[m - i] % P;
      long long now = (now1 - now2) % P;
      if (now < 0) now += P;
      now = now * a[2 * i + 1] % P;
      ans = (ans + now) % P;
    }
    printf("%I64d\n", ans);
  }
  if (n % 2 == 0) {
    m = n / 2 - 1;
    f[0] = inv[0] = 1;
    for (i = 1; i <= m; i++) {
      f[i] = f[i - 1] * (long long)i % P;
      inv[i] = inv[i - 1] * poww(i, P - 2) % P;
    }
    ans1 = 0;
    ans2 = 0;
    for (i = 0; i <= m; i++) {
      long long now = f[m] * inv[i] % P * inv[m - i] % P;
      now = now * a[2 * i + 1] % P;
      if (now < 0) now += P;
      ans1 = (ans1 + now) % P;
    }
    for (i = 0; i <= m; i++) {
      long long now = f[m] * inv[i] % P * inv[m - i] % P;
      now = now * a[2 * i + 2] % P;
      if (now < 0) now += P;
      ans2 = (ans2 + now) % P;
    }
    if (n % 4 == 0)
      ans1 = (ans1 - ans2) % P;
    else
      ans1 = (ans1 + ans2) % P;
    if (ans1 < 0) ans1 += P;
    printf("%I64d\n", ans1);
  }
}
