#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const long long int INF = LLONG_MAX;
const long long int mod = 1e9 + 7;
long long int powfunc(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int val1 = powfunc(a, b / 2);
  val1 = (val1 * val1) % mod;
  if (b % 2 != 0) val1 = (val1 * a) % mod;
  return val1;
}
long long int findNcR(long long int n, long long int r,
                      vector<long long int> &fact) {
  if (r > n) return 0;
  long long int val1 = fact[n];
  long long int val2 = powfunc(fact[r], mod - 2);
  long long int val3 = powfunc(fact[n - r], mod - 2);
  long long int val4 = (val1 * val2) % mod;
  val4 = (val4 * val3) % mod;
  return val4;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[0];
    return 0;
  }
  long long int vari = 2e5 + 2;
  vector<long long int> fact(vari);
  fact[0] = 1;
  for (long long int i = 1; i <= vari - 1; i++)
    fact[i] = (fact[i - 1] * i) % mod;
  long long int final = 0;
  if (n % 2 != 0) {
    for (long long int i = 0; i <= n - 2; i++) {
      if (i % 2 == 0)
        a[i] = (a[i] + a[i + 1] + mod) % mod;
      else
        a[i] = (a[i] - a[i + 1]) % mod;
    }
    n--;
  }
  for (long long int i = 0; i < n; i += 2) {
    long long int val1 = findNcR(n / 2 - 1, i / 2, fact);
    long long int val2 = 0;
    if (n % 4 == 0)
      val2 = (a[i] - a[i + 1] + mod) % mod;
    else
      val2 = (a[i] + a[i + 1] + mod) % mod;
    long long int val3 = (val1 * val2) % mod;
    final = (final + val3 + mod) % mod;
  }
  cout << final << endl;
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
