#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long double PI = 3.14159265;
long long int powerWithMod(long long int base, long long int exponent,
                           long long int modulus = LLONG_MAX) {
  long long int result = 1;
  base %= modulus;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent >>= 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long int modInverse(long long int a, long long int m = MOD) {
  return powerWithMod(a, m - 2, m);
}
int n, flag = 1;
long long int a[212345], fact[212345], inv[212345], ans;
void f() {
  fact[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= (int)2e5; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= MOD;
    inv[i] = modInverse(fact[i]);
  }
}
void red() {
  for (int i = 0; i < n - 1; i++) {
    if (flag)
      a[i] = (a[i] + a[i + 1]) % MOD;
    else
      a[i] = (a[i] - a[i + 1]) % MOD;
    flag = 1 - flag;
  }
}
long long int C(long long int n, long long int k) {
  return (((fact[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  f();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n % 4 == 3) {
    red();
    n--;
  }
  if (n % 4 == 1) {
    for (int i = 0; i <= n / 2; i++) {
      ans += (a[2 * i] * C(n / 2, i)) % MOD;
      ans %= MOD;
    }
  } else if (n % 4 == 2) {
    for (int i = 0; i < n / 2; i++) {
      ans += (a[2 * i] * C(n / 2 - 1, i)) % MOD;
      ans = (ans % MOD + MOD) % MOD;
      ans += (a[2 * i + 1] * C(n / 2 - 1, i)) % MOD;
      ans = (ans % MOD + MOD) % MOD;
    }
  } else if (n % 4 == 0) {
    for (int i = 0; i < n / 2; i++) {
      ans += (a[2 * i] * C(n / 2 - 1, i)) % MOD;
      ans %= MOD;
      ans -= (a[2 * i + 1] * C(n / 2 - 1, i)) % MOD;
      ans = (ans % MOD + MOD) % MOD;
    }
  }
  ans = (ans % MOD + MOD) % MOD;
  cout << ans << "\n";
  return 0;
}
