#include <bits/stdc++.h>
using namespace std;
long long N = 10000 * 100000 + 7;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long xx, yy;
  long long g = gcd(b, a % b, xx, yy);
  x = yy;
  y = xx - (a / b) * yy;
  return g;
}
long long reverse(long long k) {
  long long x, y;
  gcd(N, k, x, y);
  while (y < 0) y += N;
  y = y % N;
  return y;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  if (n == 2) {
    cout << (a[0] + a[1]) % N << endl;
    return 0;
  }
  if (n == 3) {
    cout << (a[0] + 2 * a[1] - a[2] + N) % N << endl;
    return 0;
  }
  int k = n / 4;
  k *= 2;
  if (n % 4 == 0) {
    k -= 1;
  }
  long long p[n], comb[k + 1], fac[k + 1][2];
  memset(p, 0, sizeof(p));
  fac[0][0] = 1;
  fac[0][1] = 1;
  fac[1][0] = 1;
  fac[1][1] = 1;
  for (int i = 2; i <= k; i++) {
    fac[i][0] = (fac[i - 1][0] * i) % N;
    fac[i][1] = reverse(fac[i][0]);
  }
  for (int i = 0; i <= k; i++) {
    comb[i] = (fac[k][0] * fac[i][1]) % N * fac[k - i][1] % N;
  }
  switch (n % 4) {
    case 1:
      for (int i = 0; i <= k; i++) p[i * 2] = comb[i];
      break;
    case 2:
      for (int i = 0; i < n; i++) p[i] = comb[i / 2];
      break;
    case 3:
      p[0] = 1;
      p[n - 1] = -1;
      p[(n - 1) / 2] = 2 * comb[k / 2];
      for (int i = 0; i < k / 2; i++) {
        p[2 * i + 1] = p[n - 2 * i - 2] = 2 * comb[i];
        p[2 * i + 2] = comb[i + 1] - comb[i];
        p[n - 2 * i - 3] = -p[2 * i + 2];
      }
      break;
    case 0:
      for (int i = 0; i < n / 2; i++) {
        p[2 * i] = comb[i];
        p[2 * i + 1] = -comb[i];
      }
      break;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += p[i] * a[i];
    ans = ans % N;
  }
  while (ans < 0) ans += N;
  cout << ans << endl;
  return 0;
}
