#include <bits/stdc++.h>
using namespace std;
int n, i, j;
long long v[200011], data[200011], aux[200011];
long long fact[200011], inv_fact[200011];
long long get_value(int n, int k) {
  static long long data[200011];
  int i, op;
  memset(data, 0, sizeof(data));
  data[k] = 1;
  op = 1;
  for (; n > 1; n--) {
    for (i = 1; i < n; i++, op ^= 1) {
      if (op)
        data[i] += data[i + 1];
      else
        data[i] -= data[i + 1];
    }
  }
  return data[1];
}
long long poww(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return ans;
}
long long comb(long long n, long long k) {
  long long ans = (fact[n] * inv_fact[k]) % 1000000007;
  ans = (ans * inv_fact[n - k]) % 1000000007;
  return ans;
}
void solve(int n) {
  int i, k;
  if (n % 4 == 0) {
    k = n / 4;
    for (i = 0; i <= 2 * k - 1; i++) {
      data[2 * i] = comb(2 * k - 1, i);
      data[2 * i + 1] = 1000000007 - data[2 * i];
    }
  }
  if (n % 4 == 1) {
    k = n / 4;
    for (i = 0; i <= 2 * k; i++) {
      data[2 * i] = comb(2 * k, i);
      data[2 * i + 1] = 0;
    }
  }
  if (n % 4 == 2) {
    k = n / 4;
    for (i = 0; i <= 2 * k; i++) {
      data[2 * i] = comb(2 * k, i);
      data[2 * i + 1] = data[2 * i];
    }
  }
  if (n % 4 == 3) {
    solve(n - 1);
    memcpy(aux, data, sizeof(aux));
    memset(data, 0, sizeof(data));
    for (i = 0; i <= n - 1; i++) {
      data[i] += aux[i + 1];
      if (i % 2 == 0)
        data[i + 1] += aux[i + 1];
      else
        data[i + 1] += 1000000007 - aux[i + 1];
    }
  }
  for (i = n; i > 0; i--) data[i] = data[i - 1] % 1000000007;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &v[i]);
  fact[0] = 1;
  for (i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
  inv_fact[n] = poww(fact[n], 1000000007 - 2);
  for (i = n - 1; i > 0; i--)
    inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % 1000000007;
  inv_fact[0] = 1;
  solve(n);
  long long ans = 0;
  for (i = 1; i <= n; i++) ans += v[i] * data[i], ans %= 1000000007;
  ans %= 1000000007;
  cout << ans;
  return 0;
}
