#include <bits/stdc++.h>
using namespace std;
const long long M = 2e5 + 10;
const long long INF = 1e18 + 5;
const long long MOD = 1e9 + 7;
const long long MAX = 25;
const long long N = 1e7 + 5;
const double PI = 3.14159265358979323846264338327950288419716939937510;
long long arr[M], ans, fact[M];
long long power(long long a, long long b) {
  long long an = 1;
  if (b < 0) b += MOD - 1;
  while (b) {
    if (b & 1) an = an * a % MOD;
    b >>= 1, a = a * a % MOD;
  }
  return an;
}
long long C(long long n, long long m) {
  if (m > n) return 0;
  return fact[n] * power(fact[m], MOD - 2) % MOD * power(fact[n - m], MOD - 2) %
         MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  long long c = 0;
  while (n > 0 && n % 4 != 1) {
    for (long long i = 1; i < n; i++) {
      if (c == 0)
        arr[i] = (arr[i] + arr[i + 1]) % MOD;
      else
        arr[i] = (arr[i] - arr[i + 1] + MOD) % MOD;
      c ^= 1;
    }
    n--;
  }
  if (n == 1) {
    cout << arr[1] << "\n";
    return 0;
  }
  fact[0] = 1;
  for (long long i = 1; i <= M - 5; i++) fact[i] = (fact[i - 1] * i) % MOD;
  for (long long i = 1; i <= n; i += 2) {
    long long r = i / 2;
    ans = (ans + (C((n + 1) / 2 - 1, r) * arr[i])) % MOD;
  }
  cout << ans << "\n";
}
