#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 10;
long long anum[M], bnum[M], fac[M];
long long inv(long long a) {
  return a == 1 ? 1
                : (long long)(1000000007 - 1000000007 / a) *
                      inv(1000000007 % a) % 1000000007;
}
long long C(long long n, long long m) {
  if (m < 0) return 0;
  if (n < m) return 0;
  if (m > n - m) m = n - m;
  long long up = 1, down = 1;
  for (long long i = 0; i < m; i++) {
    up = up * (n - i) % 1000000007;
    down = down * (i + 1) % 1000000007;
  }
  return up * inv(down) % 1000000007;
}
long long quick_pow(long long n, long long m) {
  long long ret = 1;
  while (m) {
    if (m & 1) ret = ret * n % 1000000007;
    n = n * n % 1000000007;
    m >>= 1;
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &anum[i]), bnum[i] = anum[i];
  if (n == 1) {
    printf("%lld\n", anum[0]);
    return 0;
  }
  if (n & 1) {
    n--;
    int flag = 1;
    for (int i = 0; i < n; i++) {
      if (flag)
        anum[i] = (bnum[i] + bnum[i + 1]) % 1000000007;
      else
        anum[i] = (bnum[i] - bnum[i + 1] + 1000000007) % 1000000007;
      flag ^= 1;
    }
  }
  n = n / 2 - 1;
  long long ans1 = 0, ans2 = 0;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = (long long)i * fac[i - 1] % 1000000007;
  for (int i = 0; i <= n; i++) {
    long long tmp =
        fac[n] * quick_pow(fac[n - i] * fac[i] % 1000000007, 1000000007 - 2) %
        1000000007;
    ans1 += anum[2 * i] * tmp % 1000000007;
    ans1 %= 1000000007;
    ans2 += anum[2 * i + 1] * tmp % 1000000007;
    ans2 %= 1000000007;
  }
  if (n % 2)
    ans1 = (ans1 - ans2 + 1000000007) % 1000000007;
  else
    ans1 = (ans1 + ans2) % 1000000007;
  printf("%lld\n", ans1);
  return 0;
}
