#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
long long a[maxn];
long long fac[maxn], inv[maxn];
const int mod = 1e9 + 7;
long long Pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long C(int n, int m) {
  if (n < m) return 0;
  return fac[n] * inv[n - m] % mod * inv[m] % mod;
}
int main() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = 1ll * fac[i - 1] * i % mod;
    inv[i] = Pow(fac[i], mod - 2);
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), a[i] %= mod;
  if (n <= 2) {
    cout << (a[1] + a[2]) % mod << endl, exit(0);
  }
  if (n % 2 != 0) {
    for (int i = 1; i < n; i++) {
      if (i % 2 != 0)
        a[i] = (a[i] + a[i + 1]) % mod;
      else
        a[i] = (a[i] - a[i + 1]) % mod;
    }
    n -= 1;
  }
  long long ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i += 2) {
    ans1 = (ans1 + C(n / 2 - 1, (i - 1) / 2) * a[i] % mod) % mod;
    ans2 = (ans2 + C(n / 2 - 1, (i - 1) / 2) * a[i + 1] % mod) % mod;
  }
  if ((1ll * n * (n - 1) / 2) % 2 == 0)
    cout << (ans1 - ans2 + mod) % mod << endl;
  else
    cout << (ans1 + ans2 + mod) % mod << endl;
  return 0;
}
