#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
long long n, i, k, res, x, s;
long long gt[200100], a[200100];
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1, d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long mod(long long a, long long b) {
  long long x, y, g = gcd(b, base, x, y);
  return (a * ((x + base) % base)) % base;
}
long long C(long long x, long long y) {
  if (y == 0) return 1;
  return mod(gt[y], (gt[x] * gt[y - x]) % base);
}
int main() {
  scanf("%lld", &n);
  s = n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  if (n == 1) {
    printf("%lld", a[1]);
    return 0;
  }
  while (n % 4 != 2) {
    n--;
    for (i = 1; i <= n; i++)
      if (i % 2 == (s - n) % 2)
        a[i] = a[i] + a[i + 1];
      else
        a[i] = a[i] - a[i + 1];
  }
  k = n / 2 - 1;
  gt[0] = 1;
  for (i = 1; i <= k; i++) gt[i] = (gt[i - 1] * i) % base;
  for (i = 1; i <= n / 2; i++) {
    if (s % 4 == 0 || s % 4 == 1)
      x = a[i * 2 - 1] - a[i * 2];
    else
      x = a[i * 2 - 1] + a[i * 2];
    if (x >= 0)
      res = (res + (x * C(i - 1, k)) % base) % base;
    else
      res = (res + base - abs(x * C(i - 1, k)) % base) % base;
  }
  printf("%lld", res);
}
