#include <bits/stdc++.h>
using namespace std;
const long long SIZE = 200050;
const long long mod = 1e9 + 7;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f * x;
}
long long n, ans;
long long num[SIZE], siz[SIZE];
inline long long quickpow(long long a, long long b) {
  long long res = 1;
  long long base = a;
  while (b) {
    if (b & 1) res = res * base % mod;
    base = base * base % mod;
    b >>= 1;
  }
  return res;
}
inline long long get_C(long long a, long long b) {
  return siz[b] * quickpow(siz[a], mod - 2) % mod *
         quickpow(siz[b - a], mod - 2) % mod;
}
inline void solve_0() {
  long long top = (n - 2) / 2, opt = 1;
  for (long long i = 1; i <= n; ++i) {
    ans += (get_C((i - 1) / 2, top) * opt * num[i]) % mod;
    ans = (ans + mod) % mod;
    opt = opt * -1;
  }
}
inline void solve_1() {
  long long top = (n - 1) / 2;
  bool opt = true;
  for (long long i = 1; i <= n; ++i) {
    if (opt) {
      ans = (ans + get_C((i - 1) / 2, top) * num[i]) % mod;
      ans = (ans + mod) % mod;
      opt = false;
      continue;
    }
    opt = true;
  }
}
inline void solve_2() {
  long long top = (n - 2) / 2;
  for (long long i = 1; i <= n; ++i) {
    ans += (get_C((i - 1) / 2, top) * num[i]) % mod;
    ans = (ans + mod) % mod;
  }
}
inline void solve_3() {
  bool opt = true;
  for (long long i = 1; i <= n; ++i) {
    if (opt) {
      num[i] = (num[i] + num[i + 1]) % mod;
    } else {
      num[i] = (num[i] - num[i + 1]) % mod;
    }
    opt = opt ^ true;
  }
  n--;
  solve_2();
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) {
    num[i] = read();
  }
  siz[0] = siz[1] = 1;
  for (long long i = 2; i <= n; ++i) {
    siz[i] = siz[i - 1] * i % mod;
  }
  bool opt = true;
  switch (n % 4) {
    case 0:
      solve_0();
      break;
    case 1:
      solve_1();
      break;
    case 2:
      solve_2();
      break;
    case 3:
      solve_3();
      break;
  }
  printf("%lld\n", ans);
}
