#include <bits/stdc++.h>
using namespace std;
inline void read_string_to_vector(vector<string> &vec) {
  string str;
  getline(cin, str);
  vec.push_back(str);
}
template <typename T>
inline void read_digit_to_vector(vector<T> &vec) {
  T t;
  cin >> t;
  vec.push_back(t);
}
long long n;
long long a[200001];
long long r[200001];
long long C[200001];
void invMult(long long m = 1000000007) {
  r[1] = 1;
  for (register long long i = 2; i < 200001; ++i)
    r[i] = (m - (((m / i) * r[m % i]) % m)) % m;
}
void cCompute(long long n) {
  C[0] = 1;
  for (register long long i = 1; i <= n; ++i)
    C[i] = (((C[i - 1] * (n - i + 1ll)) % 1000000007) * r[i]) % 1000000007;
}
void p0f(void) {
  cCompute((n - 2) >> 1);
  long long sum = 0;
  long long p = 1;
  for (register long long i = 0; i < n; ++i)
    sum = (1000000007 + sum + (a[i] * p * C[i >> 1]) % 1000000007) % 1000000007,
    p *= (-1ll);
  printf("%lld\n", sum);
}
void p1f(void) {
  cCompute((n - 1) >> 1);
  long long sum = 0;
  long long x = 0;
  for (register long long i = 0; i < n; ++i)
    sum = (1000000007 + sum + (C[x++] * a[i]) % 1000000007) % 1000000007, ++i;
  printf("%lld\n", sum);
}
void p2f(void) {
  cCompute((n - 2) >> 1);
  long long sum = 0;
  for (register long long i = 0; i < n; ++i)
    sum = (sum + 1000000007 + (C[i >> 1] * a[i]) % 1000000007) % 1000000007;
  printf("%lld\n", sum);
}
void p3f(void) {
  cCompute((n - 3) >> 1);
  long long sum = a[0] % 1000000007;
  long long x1 = 0;
  for (register long long i = 1; i < n; ++i)
    if (i & 1)
      sum = (sum + ((C[x1++] << 1) * a[i]) % 1000000007) % 1000000007;
    else
      sum = (1000000007 +
             (sum + ((C[x1 + 1] - C[x1]) * a[i]) % 1000000007) % 1000000007) %
            1000000007;
  printf("%lld\n", sum);
}
void solve1(void) {
  --n;
  long long op = 1ll;
  for (register long long i = 0; i < n; ++i)
    a[i] += a[i + 1] * op, op *= (-1ll);
}
int main() {
  scanf("%lld", &n);
  for (register long long i = 0; i < n; ++i) scanf("%lld", a + i);
  invMult();
  long long x = n % 4;
  if (!x)
    p0f();
  else if (x == 1)
    p1f();
  else if (x == 2)
    p2f();
  else
    solve1(), p2f();
  return 0;
}
