#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  for (int i = 0; i < (v.size()); ++i) os << v[i] << " ";
  os << endl;
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
const int mod = 1000000007;
long long fact[200020];
int n;
long long a[200020];
long long newa[200020];
long long P(long long x, int y) {
  if (y == 0)
    return 1;
  else {
    long long a = P(x, y / 2);
    if (y % 2 == 0)
      return (a * a) % mod;
    else
      return (a * a) % mod * x % mod;
  }
}
long long F(int k, int n) {
  long long res = fact[n];
  res = res * P(fact[k], mod - 2) % mod;
  res = res * P(fact[n - k], mod - 2) % mod;
  return res;
}
int main() {
  cout.sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) a[i] = (a[i] % mod + mod) % mod;
  fact[0] = 1;
  for (int i = (1); i <= (n); ++i) fact[i] = (fact[i - 1] * i) % mod;
  bool add = true;
  while (n % 4 != 1) {
    memset(newa, 0, sizeof(newa));
    for (int i = 0; i < (n - 1); ++i) {
      if (add) {
        newa[i] = a[i] + a[i + 1];
      } else {
        newa[i] = a[i] - a[i + 1];
      }
      add = !add;
    }
    for (int i = 0; i < (n); ++i) a[i] = (newa[i] % mod + mod) % mod;
    --n;
  }
  int k = n / 4;
  int m = 2 * k;
  long long res = 0;
  for (int i = 0; i < (n); ++i) {
    if (i % 2 != 0) {
    } else {
      long long t = a[i] * F(i / 2, m) % mod;
      res = ((res + t) % mod + mod) % mod;
    }
  }
  res = (res % mod + mod) % mod;
  cout << res << endl;
  return 0;
}
