#include <bits/stdc++.h>
using namespace std;
const int N = 200008;
const int mo = 1e9 + 7;
int n, cur, tmp;
int a[2][N];
void solve(int len) {
  cur ^= 1;
  for (int i = 1; i <= len; ++i) a[cur][i] = 0;
  for (int j = 1; j <= len; ++j) {
    ++tmp;
    if (tmp & 1)
      a[cur][j] = a[cur ^ 1][j] + a[cur ^ 1][j + 1];
    else
      a[cur][j] = a[cur ^ 1][j] + mo - a[cur ^ 1][j + 1];
    a[cur][j] %= mo;
  }
}
int mi[N], ni[N];
int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = (long long)res * x % mo;
    x = (long long)x * x % mo;
    y >>= 1;
  }
  return res;
}
int C(int x, int y) { return (long long)mi[x] * ni[y] % mo * ni[x - y] % mo; }
int main() {
  mi[0] = ni[0] = 1;
  for (int i = 1; i < N; ++i)
    mi[i] = (long long)mi[i - 1] * i % mo, ni[i] = power(mi[i], mo - 2);
  cin.sync_with_stdio(0);
  cin >> n;
  cur = tmp = 0;
  for (int i = 1; i <= n; ++i) cin >> a[cur][i];
  if (n <= 4) {
    for (int i = 2; i <= n; ++i) solve(n - i + 1);
    cout << a[cur][1] << endl;
    return 0;
  }
  int num = (n - 1) / 4 * 4 + 1;
  for (int i = n; i > num; --i) solve(i - 1);
  int ans = 0;
  for (int i = 1; i <= num; i += 2) {
    int j = (i + 1) / 2;
    ans = (ans + (long long)C((num - 1) / 2, j - 1) * a[cur][i]) % mo;
  }
  cout << ans << endl;
}
