#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int a[200010];
int fac[200010], rfac[200010];
int power(int a, int n) {
  if (!n) return 1;
  int ans = power(a, n / 2);
  ans = (long long)ans * ans % 1000000007;
  if (n & 1) ans = (long long)ans * a % 1000000007;
  return ans;
}
int pre() {
  fac[0] = rfac[0] = 1;
  for (int i = 1; i < 200010; i++) {
    fac[i] = (long long)fac[i - 1] * i % 1000000007;
    rfac[i] = power(fac[i], 1000000007 - 2);
  }
  return 0;
}
int calc(int n, int k) {
  if (k == 0) return 1;
  int ans = fac[n];
  ans = (long long)ans * rfac[n - k] % 1000000007;
  ans = (long long)ans * rfac[k] % 1000000007;
  return ans;
}
int main() {
  pre();
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) scanf("%d", a + i);
  if (N == 1) {
    cout << a[0] << endl;
    return 0;
  }
  if (N & 1) {
    N--;
    int k = 1;
    for (int i = 0; i < N; i++, k = -k) a[i] = a[i] + k * a[i + 1];
  }
  int M = N / 2;
  int s1 = 0, s2 = 0, ans = 0;
  int kk = -1;
  if (M & 1) kk = 1;
  for (int i = 0, k = 1; i < N; i += 2, k += 2) {
    s1 += (long long)calc(M - 1, i / 2) * a[i] % 1000000007;
    s1 %= 1000000007;
    s2 += (long long)calc(M - 1, i / 2) * a[k] % 1000000007;
    s2 %= 1000000007;
    ans = (long long)s1 + kk * s2 % 1000000007;
    ans %= 1000000007;
  }
  if (ans < 0) ans += 1000000007;
  cout << ans << endl;
  return 0;
}
