#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
long long a[200200];
long long fac[200200];
long long xgcd(long long a, long long &x, long long b, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1, gcd = xgcd(b, x1, a % b, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return gcd;
}
long long bin(long long n, long long k) {
  if (k < 0 || k > n) return 0;
  long long dem = (fac[n - k] * fac[k]) % md;
  long long x, y;
  xgcd(dem, x, md, y);
  while (x < 0) x += md;
  return (fac[n] * x) % md;
}
int main() {
  int n;
  scanf("%d", &(n));
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % md;
  if (n < 10) {
    int cur = 1;
    while (n > 1) {
      for (int i = 0; i < n - 1; i++) {
        if (cur)
          a[i] = (a[i] + a[i + 1]) % md;
        else
          a[i] = (a[i] - a[i + 1]) % md;
        if (a[i] < 0) a[i] += md;
        cur ^= 1;
      }
      n--;
    }
    cout << a[0] << endl;
    return 0;
  }
  long long ans = 0;
  if (n % 4 == 0) {
    long long prev = 0;
    for (int i = 0; i <= n - 1; i++) {
      if (i % 2 == 0)
        prev = bin((n - 2) / 2, i / 2);
      else
        prev = -prev;
      ans += (a[i] * prev) % md;
      ans %= md;
    }
  } else if (n % 4 == 1) {
    long long prev = 0;
    for (int i = 0; i <= n - 1; i++) {
      if (i % 2 == 0) {
        prev = bin((n - 1) / 2, i / 2);
        ans += (a[i] * prev) % md;
      }
      ans %= md;
    }
  } else if (n % 4 == 2) {
    long long prev = 0;
    for (int i = 0; i <= n - 1; i++) {
      if (i % 2 == 0) prev = bin((n - 2) / 2, i / 2);
      ans += (a[i] * prev) % md;
      ans %= md;
    }
  } else if (n % 4 == 3) {
    for (int i = 0; i <= n - 1; i++) {
      if (i % 2 == 1) {
        ans += ((a[i] * bin((n - 3) / 2, i / 2)) % md * 2) % md;
      } else {
        ans += (a[i] * (bin((n - 5) / 2, i / 2) - bin((n - 5) / 2, i / 2 - 2)) %
                md) %
               md;
      }
      ans %= md;
    }
  }
  if (ans < 0) ans += md;
  cout << ans << endl;
  return 0;
}
