#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int AwD = 1e9 + 7;
int n;
long long a[maxn];
long long b[maxn], fac[maxn];
long long AwD_pow(long long n, long long m) {
  long long ret = 1;
  while (m) {
    if (m & 1) {
      ret = ret * n % AwD;
    }
    n = n * n % AwD;
    m >>= 1;
  }
  return ret;
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      b[i] = a[i];
    }
    if (n == 1) {
      printf("%lld\n", a[0]);
      continue;
    }
    if (n & 1) {
      n--;
      int op = 0;
      for (int i = 0; i < n; i++) {
        if (!op) {
          a[i] = (b[i] + b[i + 1]) % AwD;
        } else {
          a[i] = (b[i] - b[i + 1] + AwD) % AwD;
        }
        op ^= 1;
      }
    }
    n = n / 2 - 1;
    fac[0] = 1;
    for (int i = 1; i <= n; i++) {
      fac[i] = fac[i - 1] * (long long)i % AwD;
    }
    long long ans1 = 0, ans2 = 0;
    for (int i = 0; i <= n; i++) {
      long long temp =
          fac[n] * AwD_pow(fac[i] * fac[n - i] % AwD, AwD - 2) % AwD;
      ans1 = (ans1 + temp * a[i * 2] % AwD) % AwD;
      ans2 = (ans2 + temp * a[i * 2 + 1] % AwD) % AwD;
    }
    long long ans;
    if (n & 1) {
      ans = (ans1 - ans2 + AwD) % AwD;
    } else {
      ans = (ans1 + ans2) % AwD;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
