#include <bits/stdc++.h>
using namespace std;
long long a[200010], fat[200010], inv_fat[200010];
long long binom(int a, int b) {
  return (fat[a] * ((inv_fat[a - b] * inv_fat[b]) % ((int)1e9 + 7))) %
         ((int)1e9 + 7);
}
long long mod_pow(long long b, int x) {
  if (x == 0) return 1;
  if (x & 1) return (b * mod_pow(b, x - 1)) % ((int)1e9 + 7);
  long long tmp = mod_pow(b, x / 2);
  return (tmp * tmp) % ((int)1e9 + 7);
}
int main() {
  fat[0] = inv_fat[0] = 1;
  for (int i = 1; i < 200010; i++) {
    fat[i] = (i * fat[i - 1]) % ((int)1e9 + 7);
    inv_fat[i] = mod_pow(fat[i], ((int)1e9 + 7) - 2);
  }
  int n;
  while (scanf("%d", &n) > 0) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    int sign = 1;
    while (n > 1 and !(n % 2 == 0 and sign == 1)) {
      for (int i = 1; i < n; i++) {
        a[i] = (a[i] + sign * a[i + 1] + ((int)1e9 + 7)) % ((int)1e9 + 7);
        sign *= -1;
      }
      n--;
    }
    if (n == 1) {
      printf("%lld\n", a[1]);
      continue;
    }
    long long ans = 0;
    sign = (n - 2) % 4 == 0 or (n - 2) % 4 == 3 ? 1 : -1;
    for (int i = 1, j = 0; i <= n; i += 2, j++) {
      ans = (ans +
             ((binom(n / 2 - 1, j) *
               ((a[i] + sign * a[i + 1] + ((int)1e9 + 7)) % ((int)1e9 + 7))) %
              ((int)1e9 + 7))) %
            ((int)1e9 + 7);
    }
    printf("%lld\n", ans);
  }
}
