#include <bits/stdc++.h>
using namespace std;
template <typename T0, typename T1>
std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) {
  for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) {
    os << p->first << ": " << p->second << " ";
  }
  return os;
}
template <typename T0, typename T1>
std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) {
  os << v.first << ": " << v.second << " ";
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << " ";
  }
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << endl;
  }
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const set<T>& v) {
  vector<T> tmp(v.begin(), v.end());
  os << tmp;
  return os;
}
template <typename T>
std::ostream& operator<<(std::ostream& os, const deque<T>& v) {
  vector<T> tmp(v.begin(), v.end());
  os << tmp;
  return os;
}
struct modll {
  static const long long MODVAL;
  long long val;
  modll() : val(0) {}
  modll(long long v) : val(v) { normalize(); }
  void normalize() { val = (val + MODVAL) % MODVAL; }
  modll operator+(long long v) { return modll(val + v); }
  modll& operator+=(long long v) {
    val += v;
    normalize();
    return *this;
  }
  modll operator-(long long v) { return modll(val - v); }
  modll& operator-=(long long v) {
    val -= v;
    normalize();
    return *this;
  }
  modll operator*(long long v) { return modll(val * v); }
  modll& operator*=(long long v) {
    val *= v;
    normalize();
    return *this;
  }
  modll operator^(long long e) {
    modll x(val);
    modll v(1);
    for (; e; x = x * x, e >>= 1)
      if (e & 1) v = v * x;
    return v;
  }
  modll inv() {
    modll x(val);
    return x ^ (MODVAL - 2);
  }
  static modll inv(long long v) { return modll(v).inv(); }
  operator long long() { return val; }
};
const long long modll::MODVAL = 1000000007;
modll facts[200010];
modll inv_facts[200010];
long long mod_combination(long long n, long long r) {
  assert(0 <= n && n < 200010);
  assert(0 <= r && r <= n);
  return modll(facts[n]) * inv_facts[r] * inv_facts[n - r];
}
void gen_facts() {
  facts[0] = 1;
  inv_facts[0] = modll::inv(facts[0]);
  for (int i = (int)1, _b = (int)(200010); (i) < _b; ++i)
    facts[i] = facts[i - 1] * modll(i);
  for (int i = (int)1, _b = (int)(200010); (i) < _b; ++i)
    inv_facts[i] = inv_facts[i - 1] * modll::inv(i);
  for (int i = 0, _n = (200010); (i) < (int)_n; ++i)
    assert((facts[i] * inv_facts[i]) == 1);
}
int main() {
  gen_facts();
  long long N;
  while (cin >> N) {
    vector<modll> w(N);
    for (int i = 0, _n = (N); (i) < (int)_n; ++i) {
      long long v;
      cin >> v;
      w[i] = v;
    }
    long long sign = 1;
    while (w.size() % 4 != 1) {
      vector<modll> nw(w.size() - 1);
      for (int i = 0, _n = (w.size() - 1); (i) < (int)_n; ++i) {
        nw[i] = w[i] + sign * w[i + 1];
        sign *= -1;
      }
      w = nw;
    }
    modll ans = 0;
    long long n = (w.size() - 1) / 2;
    for (int i = 0, _n = (n + 1); (i) < (int)_n; ++i) {
      ans += mod_combination(n, i) * w[2 * i];
    }
    ans += modll::MODVAL;
    cout << ans << endl;
  }
  return 0;
}
