#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
const int mod = 1e9 + 7;
long long fac[maxn], a[maxn];
void inist() {
  fac[0] = 1;
  fac[1] = 1;
  for (int i = 2; i <= maxn - 10; i++) {
    fac[i] = (fac[i - 1] * (i % mod)) % mod;
  }
}
void exgcd(long long a, long long b, long long& x, long long& y) {
  if (!b) {
    x = 1;
    y = 0;
  } else {
    exgcd(b, a % b, y, x);
    y -= x * (a / b);
  }
}
long long mod_inverse(long long a, long long m) {
  long long x, y;
  exgcd(a, m, x, y);
  return (m + x % m) % m;
}
long long C(int m, int n) {
  if (n == 0) return 1;
  long long x = fac[n] * fac[(m - n)];
  x %= mod;
  long long temp = mod_inverse(x, mod);
  return (fac[m] * temp) % mod;
}
int main() {
  int n;
  scanf("%d", &n);
  inist();
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  if (n == 1)
    printf("%lld\n", a[1] % mod);
  else if (n == 2)
    printf("%lld\n", (a[1] + a[2]) % mod);
  else if (n == 3)
    printf("%lld\n", (mod + (a[1] + a[2] + (a[2] - a[3])) % mod) % mod);
  else {
    if (n & 1) {
      for (int i = 1; i < n; i++) {
        if (i & 1)
          a[i] = a[i] + a[i + 1];
        else
          a[i] = a[i] - a[i + 1];
      }
      n--;
    }
    long long ans;
    int row = n / 2 - 1;
    long long ans1 = 0;
    int cnt = -1;
    for (int i = 1; i <= n; i += 2) {
      cnt++;
      ans1 = (ans1 % mod + a[i] * C(row, cnt)) % mod;
    }
    long long ans2 = 0;
    cnt = -1;
    for (int i = 2; i <= n; i += 2) {
      cnt++;
      ans2 = (ans2 % mod + a[i] * C(row, cnt)) % mod;
    }
    if (n % 4 == 0) {
      ans = ((ans1 - ans2) % mod + mod) % mod;
    } else
      ans = ((ans1 + ans2) % mod + mod) % mod;
    printf("%lld\n", ans);
  }
}
