#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e+9) + 7;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-12;
const long double pi = acos(-1.0);
long long a[1 << 18], b[1 << 18];
long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
long long mod_inverse(long long a, long long m) {
  long long x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
const int N_MAX = 1 << 18;
long long p[N_MAX];
void init() {
  p[0] = 1;
  for (int i = 1; i <= N_MAX - 1; i++) {
    p[i] = p[i - 1] * i % mod;
  }
}
long long comb(long long x, long long y, long long m) {
  if (x < y) return 0;
  long long res = p[x];
  (res *= mod_inverse(p[y], m)) %= mod;
  (res *= mod_inverse(p[x - y], m)) %= mod;
  return res;
}
int main() {
  init();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf(" %lld", &b[i]);
  }
  if (n == 1) {
    cout << b[0] << endl;
    return 0;
  }
  if (n % 2) {
    n--;
    for (int i = 0; i < n; i++) {
      if (i % 2) {
        a[i] = b[i] - b[i + 1];
      } else {
        a[i] = b[i] + b[i + 1];
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      a[i] = b[i];
    }
  }
  long long le = 0, ri = 0;
  for (int i = 0; i < n; i += 2) {
    int l = i / 2;
    int r = n / 2 - l - 1;
    le = ((le + comb(l + r, l, mod) * a[i] % mod) % mod + mod) % mod;
  }
  for (int i = 1; i < n; i += 2) {
    int l = i / 2;
    int r = n / 2 - l - 1;
    ri = ((ri + comb(l + r, l, mod) * a[i] % mod) % mod + mod) % mod;
  }
  if (n % 4 == 0) {
    cout << (le - ri + mod) % mod << endl;
  } else {
    cout << (le + ri) % mod << endl;
  }
  return 0;
}
