#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long mod = 1e9 + 7;
int n;
bool sign = false;
vector<long long> v;
long long fact[MAXN];
long long fastPow(long long x, long long p) {
  long long answer = 1, current = x;
  while (p != 0) {
    if (p % 2 != 0) {
      answer = (answer * current) % mod;
    }
    p /= 2;
    current = (current * current) % mod;
  }
  return answer;
}
long long inv(long long x) { return fastPow(x, mod - 2); }
vector<long long> transition(vector<long long> v) {
  vector<long long> output;
  for (int i = 0; i < v.size() - 1; i++) {
    if (sign == false)
      output.push_back((v[i] + v[i + 1]) % mod);
    else
      output.push_back((v[i] - v[i + 1] + mod) % mod);
    sign ^= true;
  }
  return output;
}
long long comb(int k, int n) {
  long long answer = fact[n];
  answer = (answer * inv(fact[n - k])) % mod;
  answer = (answer * inv(fact[k])) % mod;
  return answer;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long answer = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back((x + mod) % mod);
  }
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * 1LL * i) % mod;
  }
  while ((!(v.size() % 2 == 0 && sign == false)) && v.size() != 1) {
    v = transition(v);
  }
  if (v.size() == 1) {
    cout << v[0] % mod << '\n';
    return 0;
  }
  if (v.size() % 4 == 2) {
    for (int i = 0; i < v.size(); i++) {
      answer =
          (answer + (v[i] * comb(i / 2, (v.size() - 2) / 2)) % mod + mod) % mod;
    }
  } else {
    for (int i = 0; i < v.size(); i++) {
      if (i % 2 == 0)
        answer =
            (answer + (v[i] * comb(i / 2, (v.size() - 2) / 2)) % mod + mod) %
            mod;
      else
        answer =
            (answer - (v[i] * comb(i / 2, (v.size() - 2) / 2)) % mod + mod) %
            mod;
    }
  }
  cout << answer << '\n';
}
