#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
template <typename T>
bool cmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool cmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
template <typename T>
T read() {
  T ans = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (isdigit(ch))
    ans = (ans << 3) + (ans << 1) + (ch - '0'), ch = getchar();
  return ans * f;
}
template <typename T>
void write(T x, char y) {
  if (x == 0) {
    putchar('0'), putchar(y);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  static char wr[20];
  int top = 0;
  for (; x; x /= 10) wr[++top] = x % 10 + '0';
  while (top) putchar(wr[top--]);
  putchar(y);
}
void file() {}
int n, a[N];
void input() {
  n = read<int>();
  for (register int i = (int)(1); i <= (int)(n); ++i) a[i] = read<int>();
}
const int mo = 1e9 + 7;
int Mod(int x) { return x >= mo ? x - mo : x; }
int b[N];
int power(int x, int y) {
  int res = 1;
  for (; y; x = 1ll * x * x % mo, y >>= 1)
    if (y & 1) res = 1ll * res * x % mo;
  return res;
}
int mc[N], inv[N];
int C(int x, int y) { return 1ll * mc[x] * inv[y] % mo * inv[x - y] % mo; }
void work() {
  if (n == 1) {
    write(a[1], '\n');
    return;
  }
  if (n & 1) {
    for (register int i = (int)(1); i <= (int)(n - 1); ++i) {
      if (i & 1)
        b[i] = Mod(a[i] + a[i + 1]);
      else
        b[i] = Mod(a[i] - a[i + 1] + mo);
    }
    n--;
  } else {
    for (register int i = (int)(1); i <= (int)(n); ++i) b[i] = a[i];
  }
  mc[0] = inv[0] = 1;
  for (register int i = (int)(1); i <= (int)(n); ++i)
    mc[i] = 1ll * mc[i - 1] * i % mo;
  inv[n] = power(mc[n], mo - 2);
  for (register int i = (int)(n - 1); i >= (int)(1); --i)
    inv[i] = 1ll * inv[i + 1] * (i + 1) % mo;
  int ans = 0;
  for (register int i = (int)(1); i <= (int)(n); ++i) {
    if (i & 1 || n % 4 == 2)
      ans = Mod(ans + 1ll * C(n / 2 - 1, (i - 1) / 2) * b[i] % mo);
    else
      ans = Mod(ans - 1ll * C(n / 2 - 1, (i - 1) / 2) * b[i] % mo + mo);
  }
  write(ans, '\n');
}
int main() {
  file();
  input();
  work();
  return 0;
}
