#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long double eps = 1e-9;
long long pp = 1000000007;
long long mo(long long a, long long pp) {
  if (a >= 0 && a < pp) return a;
  a %= pp;
  if (a < 0) a += pp;
  return a;
}
long long powmod(long long a, long long b, long long pp) {
  long long ans = 1;
  for (; b; b >>= 1, a = mo(a * a, pp))
    if (b & 1) ans = mo(ans * a, pp);
  return ans;
}
long long read() {
  long long ans = 0;
  char last = ' ', ch = getchar();
  while (ch < '0' || ch > '9') last = ch, ch = getchar();
  while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
  if (last == '-') ans = -ans;
  return ans;
}
long long a[310000], b[310000], c[310000], q[310000], n, nn, inv[310000],
    q2[310000];
long long C(int n, int m) {
  if (n == m || m == 0) return 1;
  return b[n] * inv[n - m] % pp * inv[m] % pp;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  if (n == 1) {
    cout << a[1] << endl;
    return 0;
  }
  if (n == 2) {
    cout << mo(a[1] + a[2], pp) << endl;
    return 0;
  }
  nn = (n - 2) / 2;
  b[0] = 1;
  for (int i = 1; i <= nn; i++) b[i] = b[i - 1] * i % pp;
  for (int i = 0; i <= nn; i++) inv[i] = powmod(b[i], pp - 2, pp);
  for (int i = 0; i <= nn; i++) c[i] = C(nn, i);
  if (n & 1) {
    for (int i = 0; i <= nn; i++) {
      q[i * 2 + 1] = mo(c[i], pp);
      if ((n - 1) % 4 == 0)
        q[i * 2 + 2] = mo(-c[i], pp);
      else
        q[i * 2 + 2] = mo(c[i], pp);
    }
    long long ans = 0;
    int ff = 1;
    for (int i = 1; i <= n - 1; i++)
      ans = mo(ans + q[i] * (a[i] + ff * a[i + 1]), pp), ff *= -1;
    cout << ans << endl;
  } else {
    for (int i = 0; i <= nn; i++) {
      q[i * 2 + 1] = mo(c[i], pp);
      if (n % 4 == 0)
        q[i * 2 + 2] = mo(-c[i], pp);
      else
        q[i * 2 + 2] = mo(c[i], pp);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) ans = mo(ans + q[i] * a[i], pp);
    cout << ans << endl;
  }
  return 0;
}
