#include <bits/stdc++.h>
using namespace std;
long long vet[200100];
long long temp[200100];
long long exp_f(long long a, long long b) {
  long long resp = 1;
  while (b) {
    if (b & 1) resp = (resp * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return resp;
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &vet[i]);
  }
  if (n == 1) {
    printf("%lld\n", vet[0]);
    return 0;
  }
  if (n % 2) {
    n--;
    for (long long i = 0; i < n; i++) {
      if (i % 2)
        temp[i] = (vet[i] - vet[i + 1] + 1000000007) % 1000000007;
      else
        temp[i] = (vet[i] + vet[i + 1]) % 1000000007;
    }
    for (long long i = 0; i < n; i++) {
      vet[i] = temp[i];
    }
  }
  long long m = (n - 2) / 2;
  long long esp = m % 2;
  long long val = 1;
  long long pri = vet[0];
  long long sec = vet[1];
  for (long long k = 1; k <= m; k++) {
    long long ind = k << 1;
    val = ((((m - k + 1) * val) % 1000000007) * exp_f(k, 1000000007 - 2)) %
          1000000007;
    pri = (pri + val * vet[ind] % 1000000007) % 1000000007;
    sec = (sec + val * vet[ind + 1] % 1000000007) % 1000000007;
  }
  printf("%lld\n", esp ? (pri - sec + 1000000007) % 1000000007
                       : (pri + sec) % 1000000007);
  return 0;
}
