#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    T t = bigmod(p, e / 2, M);
    return (t * t) % M;
  }
  return (bigmod(p, e - 1, M) * p) % M;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T multimod(T a, T b, T m) {
  T ans = 0ll;
  a %= m, b %= m;
  while (b) {
    if (b & 1ll) ans = m - ans > a ? (ans + a) : (ans + a - m);
    b >>= 1ll;
    a = (m - a) > a ? a + a : a + a - m;
  }
  return (T)ans;
}
void sc(int &a) { scanf("%d", &a); }
void sc(long long &a) { scanf("%lld", &a); }
void sc(double &a) { scanf("%lf", &a); }
void sc(int &a, int &b) { scanf("%d %d", &a, &b); }
void sc(long long &a, long long &b) { scanf("%lld %lld", &a, &b); }
void sc(int &a, int &b, int &c) { scanf("%d %d %d", &a, &b, &c); }
void sc(int &a, int &b, long long &c) { scanf("%d %d %lld", &a, &b, &c); }
void sc(long long &a, long long &b, long long &c) {
  scanf("%lld %lld %lld", &a, &b, &c);
}
void sc(string &str) { cin >> str; }
void sc(char *(str)) { scanf(" %s", str); }
void sc(char &c) { scanf(" %c", &c); }
long long arr[(200000 + 7)];
long long tmp[(200000 + 7)];
long long fact[(200000 + 7)];
long long comb(int a, int b) {
  int c = a - b;
  long long ret = fact[a];
  long long niche = (fact[b] * fact[c]) % 1000000007;
  long long now = modinverse(niche, (long long)1000000007);
  return (now * ret) % 1000000007;
}
int main() {
  int i, j, k;
  int t, cases = 1;
  int q, u, v, m, n;
  fact[0] = 1ll;
  for (i = 1; i <= 200001; i++)
    fact[i] = (fact[i - 1] * (long long)i) % 1000000007;
  sc(n);
  for (i = 1; i <= n; i++) sc(arr[i]);
  long long ans = 0ll;
  int ok = 0;
  while (1) {
    if (n % 2 == 0 && ok == 0) break;
    for (i = 1; i < n; i++) {
      if (ok == 0)
        tmp[i] = (arr[i] + arr[i + 1]) % 1000000007;
      else
        tmp[i] = ((arr[i] - arr[i + 1]) % 1000000007 + 1000000007) % 1000000007;
      ok ^= 1;
    }
    for (i = 1; i < n; i++) arr[i] = tmp[i];
    n--;
  }
  if (n == 0) {
    cout << arr[1] << endl;
    return 0;
  }
  int every = n / 2;
  for (i = 1; i <= n; i += 2) {
    long long get = comb(every - 1, (i + 1) / 2 - 1);
    ans = (ans + (get * arr[i]) % 1000000007) % 1000000007;
  }
  every = n / 2;
  long long ans1 = 0ll;
  for (i = 2; i <= n; i += 2) {
    long long get = comb(every - 1, (i + 1) / 2 - 1);
    ans1 = (ans1 + (get * arr[i]) % 1000000007) % 1000000007;
  }
  if (n % 4 == 0)
    cout << (ans - ans1 + 1000000007) % 1000000007 << endl;
  else
    cout << (ans + ans1) % 1000000007 << endl;
  return 0;
}
