#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
long long fastPow(long long a, long long n) {
  long long res = 1;
  long long p = a;
  while (n > 0) {
    if (n % 2 == 1) {
      res *= p;
      res %= M;
    }
    p *= p;
    p %= M;
    n /= 2;
  }
  return res;
}
int modInverse(int n) { return fastPow(n, M - 2); }
int N;
long long a[200005];
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long fact = 1;
  while (N % 4 != 1) {
    for (int i = 0; i < N - 1; i++) {
      a[i] += fact * a[i + 1];
      a[i] %= M;
      fact *= (M - 1);
      fact %= M;
    }
    N--;
  }
  long long K = N / 2;
  long long sum = a[0];
  long long ni = 1;
  for (int i = 2; i < N; i += 2) {
    long long k = i / 2;
    ni *= (K - k + 1);
    ni %= M;
    ni *= modInverse(k);
    ni %= M;
    sum += ni * a[i];
    sum %= M;
  }
  cout << sum << endl;
  return 0;
}
