#include <bits/stdc++.h>
using namespace std;
void _dbg(string) { cout << endl; }
template <class H, class... T>
void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
long long mod_pow(long long x, long long n, long long p = 1000000007) {
  if (x == 0) return 0;
  long long res = 1;
  x %= p;
  while (n > 0) {
    if (n & 1) res = res * x % p;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
long long mod_inv(long long x, long long p = 1000000007) {
  return mod_pow(x % p, p - 2, p);
}
int main() {
  int n;
  cin >> n;
  vector<long long> vec(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> vec[i];
  long long mul = 1;
  while (n % 2 != 0) {
    for (int i = (int)(0); i < (int)(n - 1); i++) {
      vec[i] = vec[i] + mul * vec[i + 1];
      mul *= -1;
    }
    n--;
  }
  if (n == 0) {
    cout << vec[0] % 1000000007 << endl;
    return 0;
  }
  long long ans = 0;
  long long c = 1;
  for (int i = (int)(0); i < (int)(n); i++) {
    ans += vec[i] * c % 1000000007;
    if (i % 2 == 1) {
      long long p = n / 2 - 1;
      long long r = i / 2;
      c *= (p - r) * mod_inv(r + 1) % 1000000007;
      c %= 1000000007;
    }
    if (n % 4 != 2) c *= -1;
    ans %= 1000000007;
    while (ans < 0) ans += 1000000007;
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
