#include <bits/stdc++.h>
using namespace std;
int n;
int fu[311111], inv[311111];
int C(int n, int k) {
  return fu[n] * 1ll * inv[k] % 1000000007 * inv[n - k] % 1000000007;
}
int pv(int a, int b) {
  if (b == 0) return 1;
  long long r = pv(a, b / 2);
  r = r * r % 1000000007;
  if (b % 2) r = r * a % 1000000007;
  return r;
}
int solve(vector<int> a, int t) {
  int n = a.size();
  if (n == 1) return a[0];
  if ((n % 4 == 1 || n % 4 == 2) && t == 0) {
    int aa = (n - 1) / 2;
    int ret = 0;
    if (n % 4 == 1) {
      for (int i = 0; i < n; i++)
        if (i % 2 == 0) {
          ret = (ret + a[i] * 1ll * C(aa, i / 2)) % 1000000007;
        }
    } else {
      for (int i = 0; i < n; i++) {
        ret = (ret + a[i] * 1ll * C(aa, i / 2)) % 1000000007;
      }
    }
    return ret;
  }
  vector<int> b;
  for (int j = 0; j < n - 1; j++) {
    if (t == 0)
      b.push_back((a[j] + a[j + 1]) % 1000000007);
    else
      b.push_back((a[j] - a[j + 1] + 1000000007) % 1000000007);
    t ^= 1;
  }
  return solve(b, t);
}
int main() {
  ios::sync_with_stdio(false);
  fu[0] = 1;
  for (int i = 1; i <= 300000; i++) fu[i] = fu[i - 1] * 1ll * i % 1000000007;
  for (int i = 0; i <= 300000; i++)
    inv[i] = pv(fu[i], 1000000007 - 2) % 1000000007;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(a, 0) << endl;
  return 0;
}
