#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  cout << '(' << p.first << ' ' << p.second << ')';
  return os;
}
template <long long MOD>
class ModInt {
 public:
  const static long long mod = MOD;
  long long x;
  ModInt() { x = 0; }
  ModInt(long long x) { this->x = x < 0 ? (x + mod) % mod : x % mod; }
  int get() const { return (int)x; }
  ModInt& operator+=(ModInt that) {
    if ((x += that.get()) >= mod) x -= mod;
    return *this;
  }
  ModInt& operator-=(ModInt that) {
    if ((x += mod - that.get()) >= mod) x -= mod;
    return *this;
  }
  ModInt& operator*=(ModInt that) {
    x = x * that.get() % mod;
    return *this;
  }
  ModInt& operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const {
    using std::swap;
    long long a = x, b = mod, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int n) const {
    ModInt b = *this;
    ModInt res = 1;
    while (n != 0) {
      if (n & 1) {
        res *= b;
      }
      b *= b;
      n >>= 1;
    }
    return res;
  }
  bool operator==(ModInt that) const { return x == that.get(); }
  bool operator!=(ModInt that) const { return x != that.get(); }
  ModInt operator-() const { return x == 0 ? 0 : ModInt(mod - x); }
};
template <long long MOD>
ostream& operator<<(ostream& os, const ModInt<MOD>& m) {
  cout << m.get();
  return os;
}
template <typename T>
void dpite(T a, T b) {
  return;
}
template <typename T>
void pite(T a, T b) {
  for (T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite;
  cout << '\n';
}
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void ios_init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
int main() {
  ios_init();
  int n;
  while (cin >> n) {
    vector<int> a(n);
    for (int i = (0); i < (n); ++i) cin >> a[i];
    if (n == 1) {
      cout << a[0] << '\n';
      continue;
    }
    if (n == 2) {
      cout << ModInt<1000000007>(a[0]) + ModInt<1000000007>(a[1]) << '\n';
      continue;
    }
    if (n % 2 == 1) {
      auto tmp = a;
      a = vector<int>(n - 1);
      for (int i = (0); i < (n - 1); ++i) {
        if (i % 2 == 1)
          a[i] = tmp[i] - tmp[i + 1];
        else
          a[i] = tmp[i] + tmp[i + 1];
      }
      n--;
    }
    dpite((a).begin(), (a).end());
    vector<ModInt<1000000007> > v(n);
    for (int i = (0); i < (n); ++i) v[i] = a[i];
    if (n / 2 == 1) {
      for (int i = (0); i < (n / 2); ++i) {
        v[2 * i] *= 1;
        v[2 * i + 1] *= -1;
      }
      if (n / 2 == 1) {
        v[1] *= -1;
      }
    } else {
      ModInt<1000000007> co = 1;
      for (int i = (0); i < (n / 2); ++i) {
        true;
        true;
        v[2 * i] *= co;
        v[2 * i + 1] *= -co;
        if (n / 2 % 2 == 1) v[2 * i + 1] *= -1;
        co /= (i + 1);
        co *= (n / 2 - 1 - i);
      }
    }
    ModInt<1000000007> ans = 0;
    for (int i = (0); i < (n); ++i) ans += v[i];
    cout << ans << '\n';
  }
}
