#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '{';
  for (int i = (0), __i = (((int)(vec).size())); i < __i; i++) {
    os << vec[i];
    if (i + 1 != ((int)(vec).size())) os << ',';
  }
  os << '}';
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &par) {
  os << '(' << par.first << ',' << par.second << ')';
  return os;
}
int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
template <class T>
T sqr(T x) {
  return x * x;
}
long long a[200000];
long long fact[100000];
long long rev[100000];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = (0), __i = (n); i < __i; i++) cin >> a[i];
  if (n & 1) {
    n--;
    for (int i = (0), __i = (n); i < __i; i++)
      if (i % 2 == 0)
        a[i] = (a[i] + a[i + 1]) % 1000000007;
      else
        a[i] = (1000000007 + a[i] - a[i + 1]) % 1000000007;
  }
  if (n == 0)
    cout << a[0];
  else if (n == 2)
    cout << (a[0] + a[1]) % 1000000007;
  else {
    fact[0] = fact[1] = 1;
    rev[1] = 1;
    for (int i = (2), __i = (n / 2); i < __i; i++) {
      fact[i] = (fact[i - 1] * i) % 1000000007;
      rev[i] =
          (1000000007 - (1000000007 / i) * rev[1000000007 % i] % 1000000007) %
          1000000007;
    }
    rev[0] = 1;
    for (int i = (2), __i = (n / 2); i < __i; i++)
      rev[i] = (rev[i] * rev[i - 1]) % 1000000007;
    long long res1 = 0, res2 = 0;
    for (int i = (0), __i = (n / 2); i < __i; i++) {
      long long t = (rev[i] * rev[n / 2 - i - 1]) % 1000000007;
      res1 =
          (res1 + ((a[2 * i] * fact[n / 2 - 1]) % 1000000007) * t) % 1000000007;
      res2 = (res2 + ((a[2 * i + 1] * fact[n / 2 - 1]) % 1000000007) * t) %
             1000000007;
    }
    if ((n / 2 - 1) & 1)
      cout << (1000000007 + res1 - res2) % 1000000007;
    else
      cout << (res1 + res2) % 1000000007;
  }
  return 0;
}
