#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (n2 == 0) return n1;
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 1000000007LL;
    base = (base * base) % 1000000007LL;
    exponent /= 2;
  }
  return ans;
}
long long fact[1000005];
long long ifact[1000005];
long long arr[1000005];
long long xyz[1000005];
int main() {
  long long ans = 0;
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i < 1000005; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= 1000000007LL;
    ifact[i] = powmod(fact[i], 1000000007LL - 2LL);
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xyz[i];
  }
  if (n == 1) {
    cout << xyz[0] << '\n';
    return 0;
  }
  if (n & 1) {
    n--;
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0)
        arr[i] = xyz[i] + xyz[i + 1];
      else
        arr[i] = xyz[i] + 1000000007LL - xyz[i + 1];
      arr[i] %= 1000000007LL;
    }
  } else {
    for (int i = 0; i < n; i++) arr[i] = xyz[i];
  }
  int m = n - 2;
  m /= 2;
  if (m & 1) {
    for (int i = 0; i < n; i++) {
      long long x = fact[m] * ifact[i / 2];
      x %= 1000000007LL;
      x *= ifact[m - i / 2];
      x %= 1000000007LL;
      long long temp = x * arr[i];
      temp %= 1000000007LL;
      if (i & 1)
        ans = ans - temp + 1000000007LL;
      else
        ans = ans + temp;
      ans %= 1000000007LL;
    }
  } else {
    for (int i = 0; i < n; i++) {
      long long x = fact[m] * ifact[i / 2];
      x %= 1000000007LL;
      x *= ifact[m - i / 2];
      x %= 1000000007LL;
      long long temp = x * arr[i];
      temp %= 1000000007LL;
      ans = ans + temp;
      ans %= 1000000007LL;
    }
  }
  assert(ans >= 0);
  cout << ans << '\n';
}
